OS/2 Procedures Language 2/REXX


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Parsing Words


The PULL instruction collects a response and puts it into system memory as 
a variable.  PULL also can be used to put each word from a group of words 
into a different variable.  In REXX, this is called parsing.  The variable 
names used in the next example are:  first, second, third, and rest. 

SAY 'Please enter three or more words'
PULL first second third rest

Suppose you enter this as your response: 

garbage in garbage out

When you press the Enter key, the procedure continues.  However, the 
variables are assigned as follows: 
      The variable first is given the value GARBAGE. 
      The variable second is given the value IN. 
      The variable third is given the value GARBAGE. 
      The variable rest is given the value OUT. 
 
 In general, each variable receives a word, without blanks, and the last 
 variable receives the rest of the input, if any, with blanks. If there 
 are more variables than words, the extra variables are assigned the null, 
 or empty, value.   

Inf-HTML End Run - Successful