Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jim Bauwens

Pages: 1 ... 17 18 [19] 20 21 ... 125
271
Lua / Re: Reuse of code/classes?
« on: October 01, 2012, 08:00:15 am »
Let my explain what my my script in the above post does.

It's a build tool that will use luna to create a tns file from a .lua file.
If the the lua file has a '--include file' comment, it will fetch the content of file, and place it instead of that comment.
So, you could have multiple programs like this:
Code: [Select]
--include 'libs/lib.lua'
--include 'libs/networking.lua'

function on.paint(gc)
.....

That way you don't need to  keep a copy of the library in every source file.

There is also the way you mentioned, storing your lib code in an external library document file, and using var.recall and loadstring to load it.
However, this is a complex and slow method. (Building the external library file, making sure you refresh the libs all the time, etc)

272
Lua / Re: Problem with on.loseFocus() function
« on: October 01, 2012, 07:10:44 am »
Also, I can see that you have already quite some experience with programming.
Take a look at https://github.com/adriweb/EEPro-for-Nspire/ , an application I made with Adriweb. It makes use of a big toolkit I made, maybe you can find some interesting stuff in it :)

273
Lua / Re: Reuse of code/classes?
« on: October 01, 2012, 07:06:32 am »
I assume that you want include 'libraries' that you make in multiple projects.
In that case, I made this: https://github.com/jimbauwens/ETK/tree/master/buildtools .
However it is important to know that this uses Luna, and not TI's SDK.

TI them self haven't created anything like this for their SDK.

274
Lua / Re: Problem with on.loseFocus() function
« on: October 01, 2012, 03:56:21 am »
Okay, here goes.

D2Editor's are special things, they have a window of there own. When selecting the D2editor, the script will already lose focus. Because of this, when you switch to another page it will not lose focus again.

Personally, I don't like to use D2editor, and have my own input objects. Anyway, let me show you how to solve this problem.
Add this line to your InputField class:
self.editor:registerFilter(editors)
Rename on.loseFocus to editors.loseFocus.
Add editors = {} before editors.loseFocus.

Try your code, it should do what you want :)

See D2Editor:registerFilter in the manual for some more info.

Edit, you could also add one line such as this to your InputField class:
Code: [Select]
self.editor:registerFilter{loseFocus=function () self:storeVariable() end}
I don't like to create functions during script runtime (it's slow), but since your inputs are created at script startup it shouldn't be a problem.

275
Lua / Re: Need help with lua
« on: October 01, 2012, 03:26:11 am »
Sending a TNS of a lua application that was created with tools pre [3.2] will make the calculator run it in apiLevel 1.0 automatically.
However, if you copy the source and want to recompile it with the latest luna or the SDK you will need to add  "platform.apilevel = '1.0' " (as ElementCoder mentioned) to the top of your script.
But, it is also perfectly possible that the script will run fine without adding that line.

So:
- all 3.0x, 3.1 TNS files containing Lua scripts created with Luna < v0.3 should run fine on 3.2 . It will automatically use the old API structure
- if you want to recompile, add "platform.apilevel = '1.0' " to the top of your script.

Or you could just script it so that it doesn't matter where you run it :)

276
Lua / Re: Problem with menu separation line
« on: October 01, 2012, 02:49:27 am »
Several members have ;)

277
Lua / Re: Problem with on.loseFocus() function
« on: September 30, 2012, 05:35:21 pm »
Ah, I see your problem. D2Editors are windows of there own, the script loses focus when you select the to enter data in them.

I need to go sleep now, so I'll post a solution to this tomorrow.
Good night :)

278
Lua / Re: Problem with menu separation line
« on: September 30, 2012, 12:41:23 pm »
I've checked, and this is indeed a bug.
I assume that the grey line has a resource id, and that the code handling the menu system in Lua used a static number for it.
This resource ID most likely changed because of some updates to resource files, but the lua coders didn't change it.
Well, that's my theory.

I'll report it to TI.

279
Lua / Re: Problem with on.loseFocus() function
« on: September 30, 2012, 11:46:37 am »
Hi Goran,

This is indeed a strange issue, and it might very well be that the computer software has a bug.
Do you experience the same problem on your handheld too ?
I've tried this code on my handheld (CX CAS 3.2+), and it's working correctly:
Code: [Select]
local t = 0
function on.paint(gc)
    gc:drawString("Times that focus got lost: " .. t, 10, 10, "top")
end

function on.loseFocus()
    t=t+1
end


So, I assume that it will be a bug with the computer software. If that is the case, I will need to send a bug report to TI.
Thank you for creating a topic about this.

Also, on.construction is only called at script startup.

280
I haven't tried your code, but I assume you put that in on.paint .
Probably what is happening is that on.paint get's called again (sometimes it does this when execution time is a bit too long), causing it too loop constantly.
But that's just a theory.

281
Lua / Re: Screen trouble on startup
« on: September 28, 2012, 02:59:11 pm »
I've studied my share of it ;)

Also, there are much more secrets to Nspire Lua than many people think. But it takes some effort to find them. But when you find then, you can do magicz.

282
Lua / Re: Screen trouble on startup
« on: September 27, 2012, 05:25:02 pm »
At the time that you call platform.window:height() / width() the window hasn't initialized yet, resulting in both functions returning 0. To fix this add this to your code:
Code: [Select]
function on.resize(w, h) width, height = w, h end

283
News / Re: Release of FormulaPro for the Nspire
« on: September 24, 2012, 01:03:52 pm »
I'm quickly going to answer some questions here.
1) Currently not, but this can be added if needed
2) Yes, it should be listed in the same manner as defined in the units file
3) Default values aren't integrated, but possible. However couldn't this lead to accidental wrong results ?
4) Could you explain more in detail ? I don't quite understand
5) Right now not, but this sure is a good idea !
6) Adding a different function that uses same variables should work, no need for anything special

Also, sorry for not hosting the web code yet, I've been pretty busy the last days with college starting..

284
Art / Re: General purpose art thread
« on: September 24, 2012, 12:58:38 pm »
Wow, nice skills !
My gimp skills have slowly been improving, finished this: http://i.imgur.com/56zRH.png.
Pretty new to the path tool, but I'm slowly getting the hang of it :)

285
Lua / Re: Look what my Nspire can do
« on: September 24, 2012, 10:17:32 am »
It would be possible if someone spends a lot of time on the subject, something that many people in the Nspire community are missing.

Pages: 1 ... 17 18 [19] 20 21 ... 125