Global

Global variables are variables that have a global visibility and duration scope in a Sage X3 process.

They are created in the [V] class. Once created, they will persist during the entire life of the Sage X3 process, unless they are destroyed by the Kill instruction.

It is recommended to avoid using this declaration and to replace it with a Local declaration because this variable is a barrier used to produce reentry code.

In previous versions of Sage X3, global variables were used to access optimization buffers for parameters. This has been replaced by the context structure even if a default context global pointer still exists ([V]GACTX).

The global variable is still used to define constants in order to avoid using literal or numeric constants in the code (for example, status values sent back by some instruction).

Syntax

Global DECLARATION1 VARIABLE(DIMENSIONS)
Global DECLARATION2 VARIABLE(SIZE)(DIMENSIONS)
Global Instance VARIABLE Using CLASS
Global Instance VARIABLE(DIMENSIONS) Using CLASS
Default Global
  • DECLARATION1 may be one of the following keywords: Tinyint, Libelle, Date, Float, Double, Decimal, Datetime, or Uuident.
  • DECLARATION2 may be one of the following keywords: Char, Schar, Clbfile, or Blbfile.
  • SIZE is a numeric value.
  • DIMENSIONS can be:
    • A single numeric value 'DIM' (where there is an array with an index range from 0 to DIM-1).
    • A range of numeric values INDEX1..INDEX2 (the index varies between INDEX1 and INDEX2).
    • Several indexes or index ranges separated by a comma (for multiple dimension arrays, up to four dimensions are possible).
  • CLASS is a class code (refers to the class or representation dictionary).

'Default Global' establishes that a declaration without a Global or Local keyword will be considered global. This type of syntax should also be avoided because it makes the scope of the created variable ambiguous.

Examples

Global Char CONSTANT_STRING(100)
Global Instance MYCONTEXT Using C_MYGLOBCLASS
Global TinyInt STATUS_ARRAY(1..20)

See also

Local, Variable, Value, Const, Tinyint, Libelle, Date, Shortint, Integer, Float, Double, Decimal, Char, Schar, Clbfile, Blbfile, Uuident, Datetime, Instance.