z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


What is a Compound Variable?

z/OS TSO/E REXX User's Guide
SA32-0982-00

Compound variables are a way to create a one-dimensional array or a list of variables in REXX. Subscripts do not necessarily have to be numeric. A compound variable contains at least one period with characters on both sides of it. The following are examples of compound variables.
FRED.5
Array.Row.Col
employee.name.phone
The first variable in a compound variable always remains a symbol with no substitution. The remaining variables in a compound variable take on values previously assigned. If no value was previously assigned, the variable takes on the uppercase value of the variable name.
first = 'Fred'
last = 'Higgins'
employee = first.last
                             /* EMPLOYEE is assigned FIRST.Higgins */
SAY employee.first.middle.last
                          /* Displays EMPLOYEE.Fred.MIDDLE.Higgins */
You can use a DO loop to initialize a group of compound variables and set up an array.
DO i = 1 TO 6
   SAY 'Enter an employee name.'
   PARSE PULL employee.i
END
If you entered the same names used in the previous example of an array, you would have a group of compound variables as follows:
employee.1 = 'Adams, Joe'
employee.2 = 'Crandall, Amy'
employee.3 = 'Devon, David'
employee.4 = 'Garrison, Donna'
employee.5 = 'Leone, Mary'
employee.6 = 'Sebastian, Isaac'
When the names are in the group of compound variables, you can easily access a name by its number, or by a variable that represents its number.
name = 3
SAY employee.name                       /* Displays 'Devon, David' */

For more information about compound variables, see z/OS TSO/E REXX Reference.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014