Page 1 of 1

Template Debug Messages

Posted: 04 Jan 2013 08:50
by brianc
I'd be interested in seeing if a template contains any logic errors like referring to an object in an onload() script that hasn't yet been initialized. These would be things that the editor wouldn't catch when coding (but potentially when loading).

Does the app or editor keep a log of such things? If so, is there a way to retrieve it?

Re: Template Debug Messages

Posted: 04 Jan 2013 09:21
by Macciza
Hi
No not really . . .

From the manual
Also note, there is no mechanism at the time for OnLoad scripts to figure out which external variables should be evaluated first. Scripts may run even though variables have not been filled yet, i.e its own tiny script hasn't yet executed. Use variable declared internal to the script instead.
Dependencies on variables that hold constant numerical values, or arrays of constant numerical values, pose no problem as they are recognized as such during script compilation. Unfortunately strings and arrays of strings are not recognized as constants. (That's why they don't display in blue in the project browser)
Bottom line is, OnLoad scripts relying on external numerical constants should all work fine, but there can be issues when depending on more complex variables, or other scripts even.

Another way around this is to use delays and cascade your Load scripts to ensure things are right when you call them . . .

Cheers
MM

Re: Template Debug Messages

Posted: 04 Jan 2013 11:28
by Softcore
Somewhat relative to the topic, I had two constants on a project:

Code: Select all

green=32768
red=8328968
These were defined in top level project hierarchy and then a "onLoad" script was using them:

Code: Select all

setattribute(Meter1,'color',green);
setattribute(Meter2,'color',green);
setattribute(Meter3,'color',green);
setattribute(Meter4,'color',green);
setattribute(Meter5,'color',green);
setattribute(Meter6,'color',green);
setattribute(Meter7,'color',green);
setattribute(Meter8,'color',green);
The script worked perfectly in Lemur 3.0.x - as in, upon loading, the "Meter" objects were all getting the "green" color attribute. After version 4 however, I had to manually enter the constant in the script (replace "green" with "32768") in order to work. Being that they were constants, and not strings or arrays, is this an expected behavior?

I can send the project in question if you want to troubleshoot.

Re: Template Debug Messages

Posted: 04 Jan 2013 12:00
by Macciza
Hi
Yes send them in to me at support and we can have a look.
Thanks for the report.
Cheers
MM

Re: Template Debug Messages

Posted: 04 Jan 2013 14:50
by Phil999
The script worked perfectly in Lemur 3.0.x - as in, upon loading, the "Meter" objects were all getting the "green" color attribute. After version 4 however, I had to manually enter the constant in the script (replace "green" with "32768") in order to work.
that's strange. Yesterday I was using a similar code, and it worked fine with v.4.0.

Re: Template Debug Messages

Posted: 04 Jan 2013 18:29
by Softcore
hear ya Phill...maybe something is corrupt in that specific project? because it was started on a 3.0.x version?

Here it is! Try it to see if it loads ok on your iPad....The multisliders are supposed to go green once its loaded - they go white here....Its kinda obvious its a "timing" issue (constants not loaded before the script is run) because if you un-tick the "onload" script and re-tick it, the objects turn green as expected.
Im also sending this to support as discussed.
ConstantNotLoading.jzml
(21.62 KiB) Downloaded 75 times
EDIT: brianc, sorry for hi-jacking the thread

Re: Template Debug Messages

Posted: 04 Jan 2013 22:09
by brianc
Macciza wrote:Hi

From the manual
Also note, there is no mechanism at the time for OnLoad scripts to figure out which external variables should be evaluated first. Scripts may run even though variables have not been filled yet, i.e its own tiny script hasn't yet executed. Use variable declared internal to the script instead.
Dependencies on variables that hold constant numerical values, or arrays of constant numerical values, pose no problem as they are recognized as such during script compilation. Unfortunately strings and arrays of strings are not recognized as constants. (That's why they don't display in blue in the project browser)
Bottom line is, OnLoad scripts relying on external numerical constants should all work fine, but there can be issues when depending on more complex variables, or other scripts even.

Another way around this is to use delays and cascade your Load scripts to ensure things are right when you call them . . .
Aha! I was sure I had read that in the manual, but I wasn't able to search for it properly yesterday.

I've considered using OnFrame scripts that execute only on a single, early frame or time. I definitely don't like that, since that means there's all of these if statements being evaluated unnecessarily each frame. I really like that your cascade idea gives them an order. Any ideas how to get that accomplished without the expense of OnFrame scripts?