Note:
For the PULL instruction to extract information from the terminal, the data
stack must be empty. More information about the data stack appears in
“Chapter 11. Storing Information in the Data Stack” on page 135.
Specifying Values when Invoking an Exec
Another way for an exec to receive input is through values specified when you
invoke the exec. For example to pass two numbers to an exec named "add", using
the EXEC command, type:
EXEC rexx.exec(add) '42 21' exec
To pass input when running an exec implicitly, simply type values (words or
numbers) after the member name.
add 42 21
These values are called an
argument.
For information about arguments, see
“Passing Arguments” on page 24.
The exec "add" uses the ARG instruction to assign the input to variables as shown
in the following example.
Example of an Exec that Uses the ARG Instruction
/**************************** REXX *********************************/
/* This exec receives two numbers as input, adds them, and
*/
/* displays their sum.
*/
/*******************************************************************/
ARG number1 number2
sum = n number2
SAY 'The sum of the two numbers is' sum'.'
ARG assigns the first number, 42, to
number1
and the second number, 21, to
number2
.
If the number of values is fewer or more than the number of variable names after
the PULL or the ARG instruction, errors can occur as described in the following
sections.
Specifying Too Few Values
When you specify fewer values than the number of variables following the PULL or
ARG instruction, the extra variables are set to null. For example, you pass only one
number to "add".
EXEC rexx.exec(add) '42' exec
The first variable following the ARG instruction,
number1
, is assigned the value 42.
The second variable,
number2
, is set to null. In this situation, the exec ends with an
error when it tries to add the two variables. In other situations, the exec might not
end in error.
Specifying Too Many Values
When you specify more values than the number of variables following the PULL or
ARG instruction, the last variable gets the remaining values. For example, you pass
three numbers to "add".
Passing Information to an Exec
22
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: ......