local variables

stephen barncard stephenREVOLUTION2 at barncard.com
Mon Dec 28 20:50:19 EST 2009


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
>



More information about the Use-livecode mailing list