This instruction consists of the keywords PARSE ARG and three comma-separated templates. (For an
ARG instruction, the source strings to parse come from arguments you specify when you call a program or
CALL a subroutine or function.) Each comma is an instruction to the parser to move on to the next string.
Example
:
/* Parsing multiple strings in a subroutine
*/
num='3'
musketeers="Porthos Athos Aramis D'Artagnon"
CALL Sub num,musketeers
/* Passes num and musketeers to sub
*/
SAY total; say fourth /* Displays: "4" and " D'Artagnon"
*/
EXIT
Sub:
parse arg subtotal, . . . fourth
total=s1
RETURN
Note that when a REXX program is started as a command, only one argument string is recognized. You
can pass multiple argument strings for parsing:
v
When one REXX program calls another REXX program with the CALL instruction or a function call.
v
When programs written in other languages start a REXX program.
If there are more templates than source strings, each variable in a leftover template receives a null string.
If there are more source strings than templates, the language processor ignores leftover source strings. If
a template is empty (two commas in a row) or contains no variable names, parsing proceeds to the next
template and source string.
Combining String and Positional Patterns: A Special Case
There is a special case in which absolute and relative positional patterns do not work identically. We have
shown how parsing with a template containing a string pattern skips over the data in the source string that
matches the pattern (see page 205). But a template containing the sequence:
v
string pattern
v
variable name
v
relative
positional pattern
does
not
skip over the matching data. A relative positional pattern moves relative to the first character
matching a string pattern. As a result, assignment includes the data in the source string that matches the
string pattern.
/* Template containing string pattern, then variable name, then
*/
/*
relative positional pattern does not skip over any data.
*/
string='REstructured eXtended eXecutor'
parse var string var1 3 junk 'X' var2 +1 junk 'X' var3 +1 junk
say var1||var2||var3 /* Concatenates variables; displays: "REXX" */
Here is how this template works:
│var1
3│
│junk 'X'│
│var2 +1│
│junk
'X'│
│var3 +1 │
│ junk │
└───┬───┘
└───┬────┘
└───┬───┘
└────┬────┘
└───┬────┘
└──┬───┘
│
│
│
│
│
│
Put
Starting
Starting
Starting
Starting
Starting
characters
at 3, put
with first
with char─
with
with char─
1 through
characters
'X' put 1
acter after
second 'X'
acter
2 in var1.
up to (not
(+1)
first 'X'
put 1 (+1)
after sec─
(Stopping
including)
character
put up to
character
ond 'X'
point is
first 'X'
in var2.
second 'X'
in var3.
put rest
3.)
in junk.
in junk.
in junk.
var1='RE'
junk=
var2='X'
junk=
var3='X'
junk=
'structured
'tended e'
'ecutor'
e'
Parsing
212
CICS TS for VSE/ESA: REXX Guide
Summary of Contents for SC34-5764-01
Page 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 2: ......
Page 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 22: ...xx CICS TS for VSE ESA REXX Guide...
Page 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Page 24: ...2 CICS TS for VSE ESA REXX Guide...
Page 40: ...18 CICS TS for VSE ESA REXX Guide...
Page 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Page 106: ...84 CICS TS for VSE ESA REXX Guide...
Page 110: ...88 CICS TS for VSE ESA REXX Guide...
Page 122: ...100 CICS TS for VSE ESA REXX Guide...
Page 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Page 124: ...102 CICS TS for VSE ESA REXX Guide...
Page 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Page 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Page 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Page 252: ...230 CICS TS for VSE ESA REXX Guide...
Page 278: ...256 CICS TS for VSE ESA REXX Guide...
Page 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Page 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Page 340: ...318 CICS TS for VSE ESA REXX Guide...
Page 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Page 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Page 400: ...378 CICS TS for VSE ESA REXX Guide...
Page 438: ...416 CICS TS for VSE ESA REXX Guide...
Page 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Page 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Page 448: ...426 CICS TS for VSE ESA REXX Guide...
Page 464: ...442 CICS TS for VSE ESA REXX Guide...
Page 466: ...444 CICS TS for VSE ESA REXX Guide...
Page 468: ...446 CICS TS for VSE ESA REXX Guide...
Page 476: ...454 CICS TS for VSE ESA REXX Guide...
Page 478: ...456 CICS TS for VSE ESA REXX Guide...
Page 479: ......
Page 480: ...SC34 5764 01...
Page 481: ...Spine information CICS TS for VSE ESA REXX Guide...