Assignments and Symbols
Avariable is an object whose value can change during the running of a REXX program. The process of
changing the value of a variable is called assigning a new value to it. The value of a variable is a single
character string, of any length, that may contain any characters.
You can assign a new value to a variable with theARG, PARSE, or PULL instructions, the VALUE built-in
function, or the variable pool interface, but the most common way of changing the value of a variable is
the assignment instruction itself. Any clause of the form:
symbol=expression;
is taken to be an assignment. The result of expression becomes the new value of the variable named by
the symbol to the left of the equal sign. Currently, on VM if you omit expression, the variable is set to the
null string. However, it is recommended that you explicitly set a variable to the null string: symbol=''.
Example:
/* Next line gives FRED the value "Frederic" */
Fred='Frederic'
The symbol naming the variable cannot begin with a digit (09) or a period. (Without this restriction on the
first character of a variable name, you could redefine a number; for example 3=4; would give a variable
called 3the value 4.)
You can use a symbol in an expression even if you have not assigned it a value, because a symbol has a
defined value at all times. A variable you have not assigned a value is uninitialized. Its value is the
characters of the symbol itself, translated to uppercase (that is, lowercase azto uppercase AZ).
However, if it is a compound symbol (described under section “Compound Symbols” on page 122), its
value is the derived name of the symbol.
Example:
/* If Freda has not yet been assigned a value, */
/* then next line gives FRED the value "FREDA" */
Fred=Freda
The meaning of a symbol in REXX varies according to its context. As a term in an expression (rather than
a keyword of some kind, for example), a symbol belongs to one of four groups: constant symbols, simple
symbols, compound symbols, and stems. Constant symbols cannot be assigned new values. You can use
simple symbols for variables where the name corresponds to a single value. You can use compound
symbols and stems for more complex collections of variables, such as arrays and lists.
Constant Symbols
Aconstant symbol starts with a digit (09) or a period.
You cannot change the value of a constant symbol. It is simply the string consisting of the characters of
the symbol (that is, with any lowercase alphabetic characters translated to uppercase).
These are constant symbols:
77
827.53
.12345
12e5 /* Same as 12E5 */
3D
17E-3
REXX General Concepts
Chapter 12. REXX General Concepts 121