Assignments and Symbols
A variable 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 can contain any characters.
You can assign a new value to a variable with the ARG, PARSE, or PULL instructions, the VALUE built-in function, or the variable pool interface. The most common way of changing the value of a variable is the assignment instruction itself. Any clause of the following form is taken to be an assignment:
symbol=expression;
expression
, the
variable is set to the null string. However, it is advisable to set a variable explicitly to the
null string: symbol=''
. For
example:/* Next line gives FRED the value "Frederic" */
Fred='Frederic'
The symbol that names the variable cannot begin with a digit
(0
-9
) 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 3
the value 4
.)
a
-z
to uppercase
A
-Z
). However, if it is a compound symbol, its value is the
derived name of the symbol (see Compound symbols). For
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), 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.