Product Site

7.4.72.2. Global environment variables

You can use the VALUE function to return a value from the Rexx global environment directory. To do so, omit newvalue and specify selector as the null string. The language processor sends the message name (without arguments) to the current environment object. The environment returns the object identified by name. If there is no such object, it returns, by default, the string name with an added initial period (an environment symbol - see Section 1.13.6, “Environment Symbols”).

Here are some examples:
Example 7.98. Builtin function VALUE
-- assume the environment name MYNAME identifies the string "Simon"
name = value("MYNAME", , "")       -- sends MYNAME message to the environment
say "Hello," name                  -- "Hello, Simon"

-- Assume the environment name NONAME does not exist
name = value("NONAME", , "")       -- sends NONAME message to the environment
say "Hello," name                  -- "Hello, .NONAME"

You can use the VALUE function to change a value in the global environment directory. Include a newvalue and specify selector as the null string. The language processor sends the message name (with = appended) and the single argument newvalue to the environment object. After receiving this message, the environment identifies the object newvalue by the name name.

Here is an example:
Example 7.99. Builtin function VALUE
call value "MYNAME", "David", ""   -- sends MYNAME=("David") message to the environment
say "Hello," value("MYNAME", , "") -- "Hello, David"