Globals are a collection of user-defined variables that are maintained by xPLHal. If you need to maintain any state information in your scripts, you should store it in the globals collection.
The globals collection is non-volatile, meaning it is written to disk to ensure that the state of all globals is maintained across system restarts. The globals collection is also replicated to other xPLHal servers that are configured as slaves in a replicated environment.
To set the value of a global
The following code demonstrates setting the valu eof a global.
Note that if a global does not exist, it will be created the first time you attempt to write a value to it.
sys.value("MyGlobal") = "my string"
Although you can store any value in a global, we recommend you store only strings and numbers. Attempting to store references to complex data types, or ActiveX objects could result in unexpected behaviour.
To retrieve the value of a global
The following code retrieves the value of the global MyGlobal:
s = sys.value("MyGlobal")
Listing all globals
In the xPLHal Manager, clicking on the Globals node in the tree will display a list of all current globals and associated values.
In order to maintain state across system restarts, xPLHal stores the Mode and Period settings in two global variables called Mode and Period.
In order to avoid conflicts, you should not use either Mode or Period as a global name, nor should you use sys.value("Mode") or sys.value("Period") to read or set the current mode or period.
Instead you should use sys.setting("Mode") and sys.setting("Period"). For more information,
see the topics on Modes and Periods.