Script local

Eric Chatonet eric.chatonet at sosmartsoftware.com
Thu Jul 14 11:37:33 CDT 2005


Hi Muaadh,

Welcome to this list.

With Transcript, the language of Revolution, you may declare local  
and global variables: you know it :-)
But variables can be declared inside a handler or a function  
structure or outside.
When they are declared inside, it's the way you already know :-)
When a variable is declared outside any handler or function, its  
value is shared by all handlers and functions in the script where it  
has been declared. And it's very handy :-)
For instance, in the script of a button:

local allowDrag -- variable declared outside any handler
---------------------------------
on mouseDown
   put the mouseH & comma & the mouseV into allowDrag
end mouseDown
---------------------------------
on mouseMove x,y
   if allowDrag is empty then exit mouseMove
   set topLeft of this stack to globalLoc(x-item 1 of  
allowDrag&comma&y-item 2 of allowDrag)
end mouseMove
---------------------------------
on mouseUp
   put empty into allowDrag
end mouseUp
---------------------------------
on mouseRelease
     put empty into allowDrag
end mouseRelease
---------------------------------
on mouseLeave
   put empty into allowDrag
end mouseLeave

allowDrag value is valuable for all handlers.

Le 14 juil. 05 à 18:24, Muaadh salih a écrit :

> In the course notes notes of  BRIGHAM YOUNG UNIVERSITY   they refer  
> to a "Script-local" variable in Revolution Transcript language.   
> This is a very welcome advance so
>  that we are not stuck between a variable that is shared  by every  
> handler  in the
>  stack ( global) or a one that that is specific to one and only one  
> handler.
> A script -local ( as I expect it ) is shared by the script   
> elements ( button, field ...)
> I could not find any reference to it in the dictionary or any other  
> documentation .
> Are they correct in this ?! Any help in this matter ?!!
>




More information about the use-livecode mailing list