function(argument1,argument2,argument3,..........)
Using the ARG Instruction:
The function can receive the arguments with the
ARG instruction. Arguments are also separated by commas in the ARG instruction.
ARG arg1,arg2,arg3 .......
The names of the arguments on the function call and the ARG instruction do not
have to be the same because information is not passed by argument name but by
position. The first argument sent becomes the first argument received and so forth.
You can also set up a template in the function call, which is then used in the
corresponding ARG instruction. For information about parsing templates, see
“Parsing Data” on page 87.
The following exec sends information to an internal function that computes the
perimeter of a rectangle. The function returns a value in the variable
perim
that is
specified after the RETURN instruction. The main exec uses the value in
perim
to
replace the function call.
Notice the positional relationships between
long
and
length
, and
wide
and
width
.
Also notice that information is received from variable
perim
to replace the function
call.
Using the ARG Built-in Function:
Another way for a function to receive
arguments is with the ARG built-in function. This built-in function returns the value
of a particular argument specified by a number that represents the argument
position.
For instance, in the previous example, instead of the ARG instruction,
ARG length, width
you can use the ARG function as follows:
length = ARG(1)
/* puts the first argument into length */
width = ARG(2)
/* puts the second argument into width */
More information about the ARG function appears in
.
Example of an Internal Function
/* This exec receives as arguments the length and width of a
*/
/******************************** REXX *********************************** /
/* rectangle and passes that information to an internal function
*/
/* named perimeter. The function then calculates the perimeter of */
/*************************************************************************** /
/* the rectangle.
*/
PARSE ARG long wide
SAY 'The perimeter is' perimeter(long,wide) 'inches.'
EXIT
perimeter:
ARG length, width
perim = 2 * 2 * width
RETURN perim
Writing a Function
82
z/OS V1R1.0 TSO/E REXX User’s Guide
Содержание TSO/E REXX
Страница 1: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 2: ......
Страница 3: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 10: ...viii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 12: ...x z OS V1R1 0 TSO E REXX User s Guide ...
Страница 14: ...xii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 18: ...xvi z OS V1R1 0 TSO E REXX User s Guide ...
Страница 20: ...2 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 58: ...Tracing Expressions with the TRACE Instruction 40 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 78: ...60 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 86: ...Built In Functions 68 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 128: ...Issuing Other Types of Commands from an Exec 110 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 136: ...Debugging Execs 118 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 170: ...Protecting Elements in the Data Stack 152 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 201: ...Part 3 Appendixes Copyright IBM Corp 1988 2001 183 ...
Страница 202: ...184 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 222: ...Using Variables 204 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 226: ...208 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 238: ...220 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 241: ......