Script local variables
Peter W A Wood
peterwawood at gmail.com
Sat Feb 22 19:49:29 EST 2014
Hi Jacque
On 23 Feb 2014, at 02:56, J. Landman Gay wrote:
> It is, but there's a bug in it somewhere. I use script locals extensively and they always worked until somewhere around version 6.x. After that the values were occasionally lost. Every subsequent version has made the problem worse, and now I lose them so often that I've had to add a reload of the values to almost every handler I'm debugging.
> Since I can't find a consistent recipe (sometimes they do work) I haven't reported it yet, but it's making my life difficult. All I know is that it happens some time after I change a script, but not every time, so I'm at a loss.
With everyone's help, I think that I have found a recipe that demonstrates the problem. Perhaps somebody else could try it. I build a simple stack with a scrolling field ("Field") and a button ("Button"). The stack script is this:
local tMyScriptLocal1
local tMyScriptLocal2 = "ghijk"
local tMyScriptLocal3
on openStack
put "abcde" into tMyScriptLocal1
end openStack
command initLocal3
put "lmnop" into tMyScriptLocal3
end initLocal3
on buttonClick
initLocal3
put tMyScriptLocal1 & linefeed after Field "Field"
put tMyScriptLocal2 & linefeed after Field "Field"
put tMyScriptLocal3 & linefeed after Field "Field"
end buttonClick
The Button script is this:
on mouseUp
buttonClick
end mouseUp
If you run the script in the IDE, a button click will display:
abcde
ghijk
lmnop
Now Save As Standalone and then click the button again. It will display:
ghijk
lmnop
If somebody can confirm this behaviour, I will submit it to the QA Centre (either adding it to the existing report or adding a new one).
Regards
Peter
More information about the use-livecode
mailing list