Error getting tags :
error 404Error getting tags :
error 404 global | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
global
Basics
Expander triangle
Type
Command
Syntax
global variableNameList
Introduced
1.0
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
None required
Summary
Declares a global variable.
Examples

global currentDate
global thisThing,thatThing,theOtherThing

Additional Comments
Expander triangle

Use the global command to define a variable that can be used in any handler, and which retains its value between handlers.

Parameters:

The variableNameList is a list of global variables separated by commas.

Comments:

You can place the global command either in a handler, or in a script but outside any handler in the script:

* If you declare the global in a handler, the global declaration must appear in each handler in which you use the global. If you declare a global in one handler, and try to use it in another without first declaring it in that handler, the second handler treats it as a local variable, and it does not retain its value between handlers.

The global command can appear anywhere in a handler, as long as it's before the first statement in which the global variable is used. However, to make them easier to find, all global declarations are usually placed at the beginning of a handler:

on mouseUp

global userName

ask "Please enter your favorite color," && userName

set the backdrop to it

end mouseUp

* If you declare a global command in a script, but outside any handlers in the script, the global can be used by any handler that comes after the global declaration in that script. You don't need to declare such a global again in the handler itself.

Such global commands are usually placed at the beginning of the script, before any handlers, to make them easy to find:

global userName

on mouseUp

ask "Please enter your favorite color," && userName

set the backdrop to it

end mouseUp

User Comments
Expander triangle
User thumbnail
wolff@moz.ac.at
StarStarStarStarStar
Dec 18, 2010
A global command in a script, inside or outside any handlers in that script, retains its value for use in any handler in any subsequent script in the same stack or any substack if declared properly in this subsequent script.