Passing Arguments; Passing Arguments Using The Call Instruction Or Rexx Function Call; Passing Arguments Using The Exec Command - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Passing Information to an Exec
3. first = 13, second = 13, third = 13, fourth = 13, fifth = null
4. lastname = WEBER, firstname = JOE, score = 91
5. lastname = Baker, firstname = Amanda, score = Marie 95
6. lastname = Callahan, firstname = Eunice, score = 88

Passing Arguments

Values passed to an exec are usually called arguments. Arguments can consist of
one word or a string of words. Words within an argument are separated by blanks.
The number of arguments passed depends on how the exec is invoked.
Passing Arguments Using the CALL Instruction or REXX
Function Call
When you invoke a REXX exec using either the CALL instruction or a REXX
function call, you can pass up to 20 arguments to an exec. Each argument must be
separated by a comma.

Passing Arguments Using the EXEC Command

When you invoke a REXX exec either implicitly or explicitly using the EXEC
command, you can pass either one or no arguments to the exec. Thus the ARG
instruction in the preceding examples received only one argument. One argument
can consist of many words. The argument, if present, will appear as a single string.
If you plan to use commas within the argument string when invoking a REXX exec
using the EXEC command, special consideration must be given. For example, if
you specify:
GETARG 1,2
or
ex 'sam.rexx.exec(getarg)' '1,2'
the exec receives a single argument string consisting of "1,2". The exec could then
use a PARSE ARG instruction to break the argument string into the
comma-separated values like the following:
PARSE ARG A ',' B
SAY 'A is ' A
SAY 'B is ' B
However, because commas are treated as separator characters in TSO/E, you
cannot pass an argument string that contains a leading comma using the implicit
form of the EXEC command. That is, if you invoke the exec using:
GETARG ,2
the exec is invoked with an argument string consisting of "2". The leading comma
separator is removed before the exec receives control. If you need to pass an
argument string separated by commas and the leading argument is null (that is,
contains a leading comma), you must use the explicit form of the EXEC command.
For example:
ex 'sam.rexx.exec(getarg)' ',2'
In this case, the exec is invoked with an argument string consisting of ",2".
For more information about functions and subroutines, see "Chapter 6. Writing
Subroutines and Functions" on page 69. For more information about arguments, see
"Parsing Multiple Strings as Arguments" on page 92.
24
z/OS V1R1.0 TSO/E REXX User's Guide
/* Will say 'A is 1' */
/* Will say 'B is 2' */

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents