Global


Syntax
Global[.<type>] <variable[.<type>]> [= <expression>] [, ...]
Description
Global provides the ability for variables to be defined as global, i.e., variables defined as such may then be accessed within a Procedure. In this case the command Global must be called for the according variables, before the declaration of the procedure. Each variable may have a default value directly assigned to it. If a type is specified for a variable after Global, the default type is changed through the use of this declaration. Global may also be used with arrays, lists and maps.

In order to use local variables within a procedure, which have the same name as global variables, take a look at the Protected and Static keywords.

Example: With variables

  Global a.l, b.b, c, d = 20
  
  Procedure Change()
    Debug a  ; Will be 10 as the variable is global
  EndProcedure
  
  a = 10
  Change()

Example: With array

  Global Dim Array(2)
  
  Procedure Change()
    Debug Array(0)  ; Will be 10 as the array is global
  EndProcedure
  
  Array(0) = 10
  Change()

Example: With default type

  ; 'Angle' and 'Position' will be a float, as they didn't have a specified type
  ;
  Global.f Angle, Length.b, Position