z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


ARG (Argument)

z/OS TSO/E REXX Reference
SA32-0972-00

Read syntax diagramSkip visual syntax diagram
>>-ARG(--+---------------+--)----------------------------------><
         '-n-+---------+-'      
             '-,option-'        

returns an argument string or information about the argument strings to a program or internal routine.

If you do not specify n, the number of arguments passed to the program or internal routine is returned.

If you specify only n, the nth argument string is returned. If the argument string does not exist, the null string is returned. The n must be a positive whole number.

If you specify option, ARG tests for the existence of the nth argument string. The following are valid options. (Only the capitalized and highlighted letter is needed; all characters following it are ignored.)
Exists
returns 1 if the nth argument exists; that is, if it was explicitly specified when the routine was called. Returns 0 otherwise.
Omitted
returns 1 if the nth argument was omitted; that is, if it was not explicitly specified when the routine was called. Returns 0 otherwise.
Here are some examples:
/*  following "Call name;" (no arguments) */
ARG()         ->    0
ARG(1)        ->    ''
ARG(2)        ->    ''
ARG(1,'e')    ->    0
ARG(1,'O')    ->    1

/*  following "Call name 'a',,'b';" */
ARG()         ->    3
ARG(1)        ->    'a'
ARG(2)        ->    ''
ARG(3)        ->    'b'
ARG(n)        ->    ''    /* for n>=4 */
ARG(1,'e')    ->    1
ARG(2,'E')    ->    0
ARG(2,'O')    ->    1
ARG(3,'o')    ->    0
ARG(4,'o')    ->    1
Note:
  1. The number of argument strings is the largest number n for which ARG(n,'e') would return 1 or 0 if there are no explicit argument strings. That is, it is the position of the last explicitly specified argument string.
  2. Programs called as commands can have only 0 or 1 argument strings. The program has 0 argument strings if it is called with the name only and has 1 argument string if anything else (including blanks) is included with the command.
  3. You can retrieve and directly parse the argument strings to a program or internal routine with the ARG or PARSE ARG instructions. (See ARG, PARSE, and Parsing.)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014