GlobalVarInc Function

Action

Increments the value of a global integer variable. Global variables are accessible for all users on all agents.

Note: You do not need to initialize a global variable before you increment it for the first time. This is done automatically, in the course of which the value of the variable is set to 0.

Include file

Kernel.bdh

Syntax

GlobalVarInc( in  sVariable : string,
              in  nInc      : number,
              out nValue    : number,
              in  nTimeout  : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sVariable Name of the global variable whose value is to be incremented.
nInc Number that is added to the value of the specified global variable.
nValue Variable receiving the value of the global variable after the increment operation.
nTimeout Optional: Timeout for incrementing the value in seconds. If the specified time period is exceeded, Silk Performer indicates an error.

The function’s default behavior is to wait until the increment operation is done.

Example

dcltrans
  transaction TInit
  begin
    if GetUserID() = 1 then
      GlobalVarSet("global counter", 1000);
    end;
    GlobalWaitFor("All", ALL_USERS);
  end TInit;
 
  transaction TMain
  var
    nCount: number;
  begin
    GlobalVarInc("global counter", 10, nCount);
    writeln(nCount);
  end TMain;