I copied a section of script from within a complex “repeat” loop within a
complex function into another, smaller and less complex inline function. So
far, so good. Then, I ran into a condition in the new function that happens
about once every 500 records, and only under a rare set of circumstances.
It caused an interesting execution time error. I thought it was related to
“eof” processing, because that was the LC bug that recently caused me
frustrating fits. Not so. It took me quite a bit of whittling down logic
and running bunches of tests to recreate the rare set of circumstances.
Much fiddling later, I discovered the issue. It was a runtime “oops”.
Check out the following code snippet, which shows the execution error. I
threw it into button “Capture”s script:
on testOOPS
put 1 into t1 -- Superfluous for testing purposes
put 2 into t2 -- Superfluous for testing purposes
if true = true then -- Runtime error here !!!
exit repeat
end if
put 3 into t3 -- Superfluous for testing purposes
end testOOPS
<<<<
button "Capture": execution error at line 27 (Handler: error in statement),
char 1
I certainly didn’t expect an execution error on an “if true then” statement.
The problem is the code I copied included an “exit repeat”, but the function
I copied it into didn’t have a “repeat ... end repeat”. Thus, there was an
“unmatched” exit from a repeat that didn’t exist. On the rare occurrences
when my code matched the complex condition, it caused an execution error on
the line BEFORE the “exit repeat”. (the same thing happens on an “end
repeat”)
It seems to me this is a bug that should have been caught during the script
compilation phase, instead of during execution. somehow indicating a
runtime error on the prior statement. It cost me several hours and some
lost data to figure it out, primarily because of the rare circumstances that
caused it to happen. Note that some other lines in that script got
"dorked". I don't know if it was the "oops" or the manual changes trying to
narrow down the error while I was frustrated. I don't THINK running a
script can modify code, but I also didn't THINK I could get an execution
error on an "if true then" statement.
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode