Util.GetGlobalVar

Top  Previous  Next

 

Syntax

function Util.GetGlobalVar(VarName: string; DefaultValue: variant): variant

 

Alternative Names

ibec_GetGlobalVar

 

Description

Retrieves the value for the global variable identified by VarName previously set by Util.SetGlobalVar, if the variable has not been previously set (it can't be found in the list of global variables), the DefaultValue is returned.

 

The Return Value is either the variable value or the given default value.

 

See Also

Util.SetGlobalVar
Util.FreeGlobalVar

 

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