Parsing Multiple Strings As Arguments; Exercise - Practice With Parsing - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Parsing Data
For more information about parsing, see z/OS TSO/E REXX Reference.

Parsing Multiple Strings as Arguments

When passing arguments to a function or a subroutine, you can specify multiple
strings to be parsed. Arguments are parsed with the ARG, PARSE ARG, and
PARSE UPPER ARG instructions.
To pass multiple strings, separate each string with a comma. This comma is not a
string separator as illustrated in the example on page 90, although you can also
use a string separator within an argument template.
The following example passes three arguments separated by commas to an internal
subroutine. The first argument consists of two words "String One" that are parsed
into three variable names. The third variable name is set to null because there is no
third word. The second and third arguments are parsed entirely into variable names
string2 and string3.
CALL sub2 'String One', 'String Two', 'String Three'
EXIT
sub2:
PARSE ARG word1 word2 word3, string2, string3
For more information about passing multiple arguments, see z/OS TSO/E REXX
Reference.

Exercise - Practice with Parsing

What are the results of the following parsing examples?
92
z/OS V1R1.0 TSO/E REXX User's Guide
You can define and use variables to provide further flexibility of a PARSE VAR
instruction. Define the variable prior to the parse instruction, such as the movex
variable in the following example. With the PARSE instruction, enclose the
variable in parenthesis, in place of a number. This variable must be an unsigned
integer. Therefore, use a sign outside the parenthesis to indicate how REXX is to
interpret the unsigned integer. REXX substitutes the numeric value for the
variable as follows:
quote = 'Ignorance is bliss.'
....+....1....+....2
movex = 3
PARSE VAR quote part5 +10 part6 +3 part7 -(movex) part8
Note: The variable movex in the previous example must be an unsigned integer.
Always code a sign prior to the parenthesis to indicate how the integer is
to be interpreted. If you do not, the variable will be interpreted as a string
separator. Valid signs are:
– A plus sign (+) indicates column movement to the right
– A minus sign (-) indicates column movement to the left
– An equal sign (=) indicates an absolute column position.
. .
.
/* variable position
/* part5 contains 'Ignorance '
/* part6 contains 'is '
/* part7 contains 'bliss.'
/* part8 contains 'is bliss.'
/* word1 contains 'String'
/* word2 contains 'One'
/* word3 contains ''
/* string2 contains 'String Two'
/* string3 contains 'String Three' */
*/
*/
*/
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents