
The following exec sends information to an internal subroutine that computes the
perimeter of a rectangle. The subroutine returns a value in the variable
perim
that is
specified after the RETURN instruction. The main exec receives the value in the
special variable "RESULT".
Notice the positional relationships between
long
and
length
, and
wide
and
width
.
Also notice how information is received from variable
perim
in the special variable
RESULT
.
Using the ARG Built-in Function:
Another way for a subroutine to receive
arguments is with the ARG built-in function. This 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
.
Receiving Information from a Subroutine
Although a subroutine can receive up to 20 arguments, it can specify only one
expression on the RETURN instruction. That expression can be:
v
A number
RETURN 55
v
One or more variables whose values are substituted or when no values were
assigned, return their names
RETURN value1 value2 value3
v
A literal string
RETURN 'Work complete.'
v
An arithmetic, comparison, or logical expression whose value is substituted.
RETURN 5 * number
Example of Passing Arguments on the CALL Instruction
/* This exec receives as arguments the length and width of a
*/
/******************************** REXX ********************************/
/**********************************************************************/
/* rectangle and passes that information to an internal subroutine. */
/* The subroutine then calculates the perimeter of the rectangle.
*/
PARSE ARG long wide
CALL perimeter long, wide
SAY 'The perimeter is' RESULT 'inches.'
EXIT
perimeter:
ARG length, width
perim = 2 * 2 * width
RETURN perim
Writing a Subroutine;
Chapter 6. Writing Subroutines and Functions
75
Содержание 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: ......