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.
Column Totals: Strict Compilation Error
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Column Totals: Strict Compilation Error
You might try double quotes around mygrid - "mygrid".
Operating System: macOS Monterey Version 12.5
LiveCode Version: 9.6.8
LiveCode Version: 9.6.8
Re: Column Totals: Strict Compilation Error
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.
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.
- Attachments
-
- column totals.zip
- (6.84 KiB) Downloaded 208 times
Re: Column Totals: Strict Compilation Error
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.
TryThat 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
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
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
That's it-- DOUBLE QUOTES are needed around ALL field and object designators in Strict Compilation mode!That should do it. Double quotes around *all* field and object designators.
Declaration of all variables (except, interestingly enough, in a repeat loop index).
Very good point-- No need to update the screen with each iteration.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.
Thanks for your help on this SparkOut!