Chapter 7. Manipulating Data
Using Compound Variables and Stems ................85
What is a Compound Variable? ..................85
Using Stems .........................86
Exercises - Using Compound Variables and Stems .........87
Parsing Data..........................87
Instructions that Parse .....................88
PULL Instruction ......................88
ARG Instruction ......................88
PARSE VAR Instruction....................89
PARSE VALUE ... WITH Instruction ...............89
Ways of Parsing .......................89
Blank ..........................89
String ..........................90
Variable .........................90
Number .........................90
Parsing Multiple Strings as Arguments ...............92
Exercise - Practice with Parsing ................92
This chapter describes how to use compound variables and stems, and shows
various ways of parsing using templates.
Using Compound Variables and Stems
Sometimes it is useful to store groups of related data in such a way that the data
can be easily retrieved. For example, a list of employee names can be stored in an
array and retrieved by number. An array is an arrangement of elements in one or
more dimensions, identified by a single name. You could have an array called
employee that contains names as follows:
EMPLOYEE
(1) Adams, Joe
(2) Crandall, Amy
(3) Devon, David
(4) Garrison, Donna
(5) Leone, Mary
(6) Sebastian, Isaac
In some computer languages, you access an element in the array by the number of
the element, such as, employee(1), which retrieves Adams, Joe. In REXX, you use
compound variables.
What is a Compound Variable?
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.
© Copyright IBM Corp. 1988, 2001 85