Shared


Syntax
Shared <variable> [, ...] 
Description
Shared allows a variable, an array, a list or a map to be accessed within a procedure. When Shared is used with an array, a list or a map, only the name followed by '()' must be specified.

Example: With variable

  a = 10
  
  Procedure Change()
    Shared a
    a = 20 
  EndProcedure 
  
  Change()
  Debug a   ; Will print 20, as the variable has been shared.

Example: With array and list

  Dim Array(2)
  NewList List()
  AddElement(List())
  
  Procedure Change()
    Shared Array(), List()
    Array(0) = 1
    List() = 2
  EndProcedure 
  
  Change()
  Debug Array(0)  ; Will print 1, as the array has been shared.
  Debug List()    ; Will print 2, as the list has been shared.