IBM SC34-5764-01 Server User Manual


 
2 │var1 4 │ 1 │var2 2│ │ 4 var3 5│ │11 var4 │
2 │var1 +2 │ │ ─3 │ │var2 +1│ │+2 var3 +1│ │+6 var4 │
└──┬──┘ └───┬────┘ └──┬───┘ └───┬───┘ └────┬─────┘ └───┬────┘
│││
Start Non─ Go to 1. Non─ Go to 4 Go to 11
at 2. inclusive (4─3=1) inclusive (2+2=4). (5+6=11).
stopping stopping Non─inclusive
point is 4 point is stopping point
(2+2=4). 2 (1+1=2). is 5 (4+1=5).
You can use templates with positional patterns to make multiple assignments:
/* Making multiple assignments */
books='Silas Marner, Felix Holt, Daniel Deronda, Middlemarch'
parse var books 1 Eliot 1 Evans
/* Assigns the (entire) value of books to Eliot and to Evans. */
Combining Patterns and Parsing Into Words
What happens when a template contains patterns that divide the source string into sections containing
multiple words? String and positional patterns divide the source string into substrings. The language
processor then applies a section of the template to each substring, following the rules for parsing into
words.
/* Combining string pattern and parsing into words */
name=' John Q. Public'
parse var name fn init '.' ln /* Assigns: fn='John' */
/* init=' Q' */
/* ln=' Public' */
The pattern divides the template into two sections:
v fn init
v ln
The matching pattern splits the source string into two substrings:
v ' John Q'
v ' Public'
The language processor parses these substrings into words based on the appropriate template section.
John had three leading blanks. All are removed because parsing into words removes leading and trailing
blanks except from the last variable.
Q has six leading blanks. Parsing removes one word-separator blank and keeps the rest because init is
the last variable in that section of the template.
For the substring ' Public', parsing assigns the entire string into ln without removing any blanks. This
is because ln is the only variable in this section of the template. (For details about treatment of blanks,
see page 204.)
/* Combining positional patterns with parsing into words */
string='REXX'
parse var string var1 var2 4 var3 6 var4 /* Assigns: var1='R' */
/* var2='E' */
/* var3=' X' */
/* var4=' X' */
The pattern divides the template into three sections:
v var1 var2
v var3
v var4
The matching patterns split the source string into three substrings that are individually parsed into words:
Parsing
208
CICS TS for VSE/ESA: REXX Guide