Page 1 of 1
Column Totals: Strict Compilation Error
Posted: Mon Jun 20, 2011 5:26 pm
by townsend
This looks fine and works fine, but when I turn on Strict Compilation mode, I get this error.
I'd like to continue using Strict Compilation. Any idea what this might be?
PS: I like the way, when you double click on the Error in the Errors Tab,
LiveCode highlights the area of the error.
Re: Column Totals: Strict Compilation Error
Posted: Mon Jun 20, 2011 6:10 pm
by jharris
You might try double quotes around mygrid - "mygrid".
Re: Column Totals: Strict Compilation Error
Posted: Mon Jun 20, 2011 6:20 pm
by townsend
Thanks for the suggestion. No. That didn't work.
Here's the Stack, in case anyone wants to look at it.
If nothing else, it's a good example on how to do column totals.
Re: Column Totals: Strict Compilation Error
Posted: Mon Jun 20, 2011 7:00 pm
by SparkOut
It *would* have worked if that had been the only place you needed to add double quotes. You also need to declare your variable in strict compilation mode.
Try
Code: Select all
on mouseUp
local theDataA
put empty into field "totals"
repeat with ii = 1 to the dgNumberOfLines of group "mygrid"
put the dgDataOfLine[ii] of group "mygrid" into theDataA
put theDataA["Value"] + field "totals" into field "totals"
end repeat
end mouseUp
That should do it. Double quotes around *all* field and object designators. Declaration of all variables (except, interestingly enough, in a repeat loop index).
Also, try adding the cumulative value in a variable and put into the display field only once at the end. It won't make a difference in the test above, but field operations are exponentially slower than variable operations (for many, and logical reasons). In a long iterative loop it will make difference to the processing time.
HTH
SparkOut
Re: Column Totals: Strict Compilation Error
Posted: Mon Jun 20, 2011 7:41 pm
by townsend
That should do it. Double quotes around *all* field and object designators.
Declaration of all variables (except, interestingly enough, in a repeat loop index).
That's it-- DOUBLE QUOTES are needed around ALL field and object designators in Strict Compilation mode!
Also, try adding the cumulative value in a variable and put into the display field only once at the end...
field operations are exponentially slower than variable operations.
Very good point-- No need to update the screen with each iteration.
Thanks for your help on this SparkOut!