Global Variables: Example Scripts
The following scripts are simple examples using global variables.
While global variables are in fact global, they still need to be declared everywhere they are used. This means that they need to be declared either within every handler where they are referenced, or simply in line with the variable.
Example 1: Once a Global, Always Global
For example, the variable "dog" in the script below must be declared in both the main script and the helper script in order to be used as a global variable.
Main Script
global dog -- Declares dog as a global var
Put "Hello" into dog -- Stores a string in dog
Test1 -- Runs Test1.script
Called Script (Test1)
global dog -- Declares dog as a global var
log dog -- Logs "Hello"