Product Site

7.4.72. VALUE

Returns the value of the symbol that name (often constructed dynamically) represents and optionally assigns a new value to it. By default, VALUE refers to the current Rexx-variables environment, but other, external collections of variables can be selected. If you use the function to refer to Rexx variables, name must be a valid Rexx symbol. (You can confirm this by using the SYMBOL function.) Lowercase characters in name are translated to uppercase for the local environment. For the global environment lowercase characters are not translated because the global environment supports mixed-case identifiers. Substitution in a compound name (see Section 1.13.5, “Compound Symbols”) occurs if possible.

If you specify newvalue, the named variable is assigned this new value. This does not affect the result returned; that is, the function returns the value of name as it was before the new assignment.

Here are some examples:
Example 7.96. Builtin function VALUE
/* After: Drop A3; A33=7; K=3; fred="K"; list.5="Hi" */
VALUE("a"k)     -->  "A3" /* looks up A3                */
VALUE("a"k||k)  -->  "7"
VALUE("fred")   -->  "K"  /* looks up FRED              */
VALUE(fred)     -->  "3"  /* looks up K                 */
VALUE(fred,5)   -->  "3"  /* looks up K and             */
                         /* then sets K=5              */
VALUE(fred)     -->  "5"  /* looks up K                 */
VALUE("LIST."k) -->  "Hi" /* looks up LIST.5            */

Notes:
  1. If the VALUE function refers to an uninitialized Rexx variable, the default value of the variable is always returned. The NOVALUE condition is not raised.
  2. The VALUE function is used when a variable contains the name of another variable, or when a name is constructed dynamically. If you specify name as a single literal string and omit newvalue and selector, the symbol is a constant and the string between the quotation marks can usually replace the whole function call. For example, fred=VALUE("k"); is identical with the assignment fred=k;, unless the NOVALUE condition is trapped. See Chapter 11, Conditions and Condition Traps.