>>-ARG--+---------------+--;----------------------------------->< +-template_list-+
ARG retrieves the argument strings provided to a program, internal routine, or method and assigns them to variables. It is a short form of the instruction:
>>-PARSE UPPER ARG--+---------------+--;----------------------->< +-template_list-+
The template_list can be a single template or list of templates separated by commas. Each template consists of one or more symbols separated by blanks, patterns, or both.
Unless a subroutine, internal function, or method is processed, the objects passed as parameters to the program are converted to string values and parsed into variables according to the rules described in Parsing.
If a subroutine, internal function, or method is processed, the data used are the argument objects that the caller passes to the routine.
The language processor converts the objects to strings and translates the strings to uppercase (that is, lowercase a-z to uppercase A-Z) before processing them. Use the PARSE ARG instruction if you do not want uppercase translation.
You can use the ARG and PARSE ARG instructions repeatedly on the same source objects (typically with different templates). The source objects do not change. The only restrictions on the length or content of the data parsed are those the caller imposes.
Example:
/* String passed is "Easy Rider" */ Arg adjective noun . /* Now: ADJECTIVE contains "EASY" */ /* NOUN contains "RIDER" */
If you expect more than one object to be available to the program or routine, you can use a comma in the parsing template_list so each template is selected in turn.
Example:
/* Function is called by FRED("data X",1,5) */ Fred: Arg string, num1, num2 /* Now: STRING contains "DATA X" */ /* NUM1 contains "1" */ /* NUM2 contains "5" */
Notes:
The ARG built-in function can also retrieve or check the arguments. See ARG (Argument).
The USE ARG instruction (see USE) is an alternative way of retrieving arguments. USE ARG performs a direct, one-to-one assignment of argument objects to Rexx variables. You should use this when your program needs a direct reference to the argument object, without string conversion or parsing. USE ARG also allows access to both string and non-string argument objects. ARG and PARSE ARG produce string values from the arguments, and the language processor then parses these.