14. GLOBAL Variables

You can define global variables which can be accessed from within the rexx whatever the current procedure variable scope is. STEMS are not supported.

SETG('variable-name', 'content')

SETG sets or updates a variable with the given content.

GETG('variable-name')

GETG returns the current content of the global variable.

Example:

 1call setg('ctime',time('l'))
 2call setg('city','Munich')
 3call testproc
 4exit 0
 5
 6testproc: procedure
 7  /* normal variable scope can't access variables from the calling rexx */
 8  say 'Global Variables from the calling REXX'
 9  say getg('ctime')
10  say getg('city')
11return 0

Result:

GLOBAL VARIABLES FROM THE CALLING REXX
19:45:12.538474
MUNICH