Util.SetGlobalVar |
Top Previous Next |
Syntax function Util.SetGlobalVar(VarName: string; VarValue: variant): integer
Alternative Names
Description Creates a global variable identified by VarName with the value VarValue. If the variable exists, its existing value will be modified to the new value. Values can be retrieved using the Util.GetGlobalVar function.
The Return Value is always 0.
Global variables will be destroyed after the script has finished, but can also be destroyed manually using Util.FreeGlobalVar.
See Also
Example execute UDSBlock as begin try /* create a few global variables */ Util.SetGlobalVar('var1', 100); Util.SetGlobalVar('var2', current_date); Util.SetGlobalVar('var3', 'this is variable 3');
/* retrieve the values for the variables */ GUI.ShowMessage('unknown var: ' || Util.GetGlobalVar('unknown var', 'not found')); GUI.ShowMessage('var1: ' || Util.GetGlobalVar('var1', 'not found')); GUI.ShowMessage('var2: ' || Util.GetGlobalVar('var2', 'not found')); GUI.ShowMessage('var3: ' || Util.GetGlobalVar('var3', 'not found')); finally /* free global variables, either one-by-one or all at the same time */ GUI.ShowMessage('free-ed ' || Util.FreeGlobalVar('var1') || ' variable.'); GUI.ShowMessage('free-ed ' || Util.FreeGlobalVar('') || ' variables.'); end; end |