local variables

Kee Nethery kee at kagi.com
Mon Dec 28 21:01:35 EST 2009


OK so there are locals that are local to a specific script, and locals to a specific handler. That's interesting. Thank you!
Kee Nethery

On Dec 28, 2009, at 5:50 PM, stephen barncard wrote:

> You are using it as a script variable. It's a local variable that is
> available from any handler in the script. If you want true local, then put
> the declaration inside the desired handler....
> 
> sqb
> -------------------------
> Stephen Barncard
> San Francisco
> http://houseofcubes.com/disco.irev
> 
> 
> 2009/12/28 Kee Nethery <kee at kagi.com>
> 
>> OK this is weird, also in 4.0. A local variable appears to be treated as a
>> global variable.
>> 
>> local x, y, myvariable
>> 
>> on mouseup
>> put empty into myvariable
>> repeat with x = 1 to 1000
>>   repeat with y = 1 to 1000
>>     put x && somefunction(y) & return after myvariable
>>   end repeat
>> end repeat
>> end mouseup
>> 
>> on somefunction y
>> repeat with x = y down to 1
>>   add 1 to y
>> end repeat
>> return y && x
>> end somefunction
>> 
>> In code that looks a lot like this, x in the mouseup gets reset to 1 after
>> somefunction(y) is called. If x was a global, OK I'd expect that, but I have
>> to declare x a local to use it and it is being treated as a global. Also, x
>> appears twice in the variable section of the debug window. What should I be
>> doing to get the behavior I used to get in 2.9?
>> 
>> Thanks, Kee
>> 
>> 
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




-------------------------------------------------
I check email roughly 2 to 3 times per business day. 
Kagi main office: +1 (510) 550-1336





More information about the use-livecode mailing list