Column Totals: Strict Compilation Error

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Column Totals: Strict Compilation Error

Post by townsend » Mon Jun 20, 2011 5:26 pm

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?
112 strict compilation error.JPG
PS: I like the way, when you double click on the Error in the Errors Tab,
LiveCode highlights the area of the error.

jharris
Posts: 84
Joined: Wed Jan 26, 2011 3:28 am

Re: Column Totals: Strict Compilation Error

Post by jharris » Mon Jun 20, 2011 6:10 pm

You might try double quotes around mygrid - "mygrid".
Operating System: macOS Monterey Version 12.5
LiveCode Version: 9.6.8

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Column Totals: Strict Compilation Error

Post by townsend » Mon Jun 20, 2011 6:20 pm

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.
114 column totals.JPG
Attachments
column totals.zip
(6.84 KiB) Downloaded 208 times

SparkOut
Posts: 2946
Joined: Sun Sep 23, 2007 4:58 pm

Re: Column Totals: Strict Compilation Error

Post by SparkOut » Mon Jun 20, 2011 7:00 pm

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

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Column Totals: Strict Compilation Error

Post by townsend » Mon Jun 20, 2011 7:41 pm

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!

Post Reply