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 may 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, 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 3 the 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 az to uppercase AZ). However, if it is a compound symbol (described under section Compound Symbols), 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.


Concept Concept

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/assinmt.html