h. SAY a.first
i. SAY z.a.4
2. After these assignment instructions, what output do the SAY instructions produce?
hole.1 = 'full'
hole. = 'empty'
hole.s = 'full'
a. SAY hole.1
b. SAY hole.s
c. SAY hole.mouse
ANSWERS
1.
a. 3
b. 4
c. last
d. A.3
e. 2
f. D.last
g. C.3
h. A.FIRST
i. cv3d
2.
a. empty
b. full
c. empty
Parsing Data
Parsing is separating data and assigning parts of it into one or more variables. Parsing can assign each
word in the data into a variable or can divide the data into smaller parts. Parsing is also useful to format
data into columns.
The variables to receive data are named in a template. A template is a model telling how to split the data.
It can be as simple as a list of variables to receive data. More complex templates can contain patterns;
section “Parsing with Patterns” on page 75 explains patterns.
Parsing Instructions
The REXX parsing instructions are PULL, ARG, and PARSE. (PARSE has several variants.)
PULL Instruction
Other chapters show PULL as an instruction that reads input and assigns it to one or more variables. If the
program stack contains information, the PULL instruction takes information from the program stack. When
the program stack is empty, PULL takes information from the current terminal input device. See section
“Getting Information from the Program Stack or Terminal Input Device” on page 14 for information about
the data stack.
/* This REXX program parses the string "Knowledge is power." */
PULL word1 word2 word3
/* word1 contains 'KNOWLEDGE' */
/* word2 contains 'IS' */
/* word3 contains 'POWER.' */
PULL uppercases character information before assigning it into variables. If you do not want uppercase
translation, use the PARSE PULL instruction.
Manipulating Data
Chapter 7. Manipulating Data 73