IBM SC34-5764-01 Server User Manual


 
DOi=1TO6
PARSE PULL employee.i
END
If you use the same names used in the example of the employee array, you 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'
After 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 /* Produces 'Devon, David' */
For more information about compound variables, see section “Compound Symbols” on page 122.
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 by using an assignment that includes a stem. For example, number.=0
initializes all array elements in the array named number. to 0.
You can change the values of all compound variables in an array the same way. For example, to change
all employee names to Nobody, use the following assignment instruction:
employee. = 'Nobody'
As a result, all compound variables beginning with the stem employee., previously assigned or not, have
the value Nobody. After a stem assignment, you can assign individual compound variables new values.
employee.='Nobody'
SAY employee.5 /* Produces 'Nobody' */
SAY employee.10 /* Produces 'Nobody' */
SAY employee.oldest /* Produces 'Nobody' */
employee.new = 'Clark, Evans'
SAY employee.new /* Produces 'Clark, Evans' */
You can use stems with the EXECIO and RFS commands when reading to and writing from a file. See
section “EXECIO” on page 344 for information about EXECIO. See section “RFS” on page 363 for
information about RFS. RFS is the preferred I/O method under CICS.
Exercises - Using Compound Variables and Stems
1. After these assignment instructions, what do the following SAY instructions produce?
a = 3 /* assigns '3' to variable 'A' */
d = 4 /* '4' to 'D' */
c = 'last' /* 'last' to 'C' */
a.d = 2 /* '2' to 'A.4' */
a.c = 5 /* '5' to 'A.last' */
z.a.d = 'cv3d' /* 'cv3d' to 'Z.3.4' */
a. SAY a
b. SAY D
c. SAY c
d. SAY a.a
e. SAY A.D
f. SAY d.c
g. SAY c.a
Manipulating Data
72
CICS TS for VSE/ESA: REXX Guide