ibec_GetGlobalVar

ibec_GetGlobalVar returns the value of a specified global Local variables / DECLARE VARIABLE statement|variable. If the variable does not exist, this function returns the value passed in DefaultValue.

Syntax

function ibec_GetGlobalVar(VarName : string; DefaultValue : variant) :variant;

Example

The following example illustrates the use of this function, together with ibec_SetGlobalVar, described within an SQL script:

   CONNECT ...;
 
   execute ibeblock
   as
   begin
     select myfield from mytable
     where something = 25
     into :MyVar;
     ibec_SetGlobalVar('MyGlobalVar', MyVar);
   end;
 
   ...
 
   execute ibeblock
   as
   begin
     MyVar = ibec_GetGlobalVar('MyGlobalVar', null);
     if (MyVar = 1) then
       insert into mytable ...;
     else if (MyVar = 2) then
       update mytable set ...;
   end;

It is also possible to specify global VAR values for IBEBlocks using the command line:

  1. G<variable_name>=<value>.

Or alternatively specify global VAR values using INI files. Please refer to IBEScript for details and examples.