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.
DOi=1TO6
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.
Using Stems
When working with compound variables, it is often useful to initialize an entire
collection of variables to the same value. You can do this easily with a stem.A
stem is the first variable name and first period of the compound variable. Thus
every compound variable begins with a stem. The following are stems:
FRED.
Array.
employee.
You can alter all the compound variables in an array through the stem. For
example, to change all employee names to Nobody, issue the following assignment
instruction:
employee. = 'Nobody'
As a result, all compound variables beginning with employee., whether or not they
were previously assigned, return the value Nobody. Compound variables that are
assigned after the stem assignment are not affected.
SAY employee.5 /* Displays 'Nobody' */
SAY employee.10 /* Displays 'Nobody' */
SAY employee.oldest /* Displays 'Nobody' */
employee.new = 'Clark, Evans'
SAY employee.new /* Displays 'Clark, Evans' */
You can use stems with the EXECIO command when reading to and writing from a
data set. For information about the EXECIO command, see “Using EXECIO to
Process Information to and from Data Sets” on page 154. You can also use stems
Using Compound Variables and Stems
86
z/OS V1R1.0 TSO/E REXX User’s Guide