EasyManuals Logo

IBM TSO/E REXX User Manual

IBM TSO/E REXX
242 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #40 background imageLoading...
Page #40 background image
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 = number1 + 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 Users Guide

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM TSO/E REXX and is the answer not in the manual?

IBM TSO/E REXX Specifications

General IconGeneral
BrandIBM
ModelTSO/E REXX
CategoryComputer Hardware
LanguageEnglish

Related product manuals