Using the ARG Instruction

About this task

A subroutine or function can receive the arguments with the ARG instruction. In the ARG instruction, commas also separate arguments.
ARG  arg1, arg2, arg3, …

The names of the arguments that are passed do not have to be the same as those on the ARG instruction because information is passed by position rather than by argument name. The first argument sent is the first argument received and so forth. You can also set up a template in the CALL instruction or function call. The language processor then uses this template in the corresponding ARG instruction. For information about parsing with templates, see section Parsing Data.

In the following example, the main routine sends information to a subroutine that computes the perimeter of a rectangle. The subroutine returns a value in the variable perim by specifying the value in the RETURN instruction. The main program receives the value in the special variable RESULT.
Figure 1. Example of Passing Arguments on the CALL Instruction
dfhrx009
The next example is the same except it uses ARG in a function instead of a subroutine.
Figure 2. Example of Passing Arguments on the Call to an Internal Routine
dfhrx012

In the two preceding examples, notice the positional relationships between long and length, and wide and width. Also notice how information is received from variable perim. Both programs include perim on a RETURN instruction. For the program with a subroutine, the language processor assigns the value in perim to the special variable RESULT. For the program using a function, the language processor replaces the function call perimeter(long,wide) with the value in perim.


Task Task

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/dfhrx00055.html