global
Type
command
Summary
Syntax
global <variableNameList>
Description
Use the global command to define a variable that can be used in any handler, and which retains its value between handlers.
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 :
- 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:
Parameters
Name | Type | Description |
---|---|---|
variableNameList | A list of global variables separated by commas. |
Examples
global gUserName
global gThisThing,gThatThing,gTheOtherThing
Related
function: globalNames, value
glossary: variable, handler, global, statement, local variable, declare, command
property: script
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile