z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Passing Arguments Using the EXEC Command

z/OS TSO/E REXX User's Guide
SA32-0982-00

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    /* Will say 'A is 1' */
SAY 'B is ' B    /* Will say 'B is 2' */
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 Writing Subroutines and Functions. For more information about arguments, see Parsing Multiple Strings as Arguments.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014