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 #98 background imageLoading...
Page #98 background image
Example of Passing Information in a Variable
/****************************** REXX *******************************/
/* This exec receives a calculated value from an internal */
/* function and displays that value. */
/*******************************************************************/
number1 = 5
number2 = 10
SAY add() /* Displays 15 */
SAY answer /* Also displays 15 */
EXIT
add:
answer = number1 + number2
RETURN answer
Using the same variables in an exec and its internal function can sometimes create
problems. In the following example, the main part of the exec and the function use
the same control variable, "i", for their DO loops. As a result, the DO loop repeats
only once in the main exec because the function returns to the main exec with i =
6.
Example of a Problem Caused by Passing Information in a Variable
/****************************** REXX *******************************/
/* This exec uses an instruction in a DO loop to call an internal */
/* function. A problem occurs because the function also uses a DO */
/* loop with the same control variable as the main exec. The DO */
/* loop in the main exec repeats only once. */
/*******************************************************************/
number1 = 5
number2 = 10
DOi=1TO5
SAY add() /* Displays 105 */
END
EXIT
add:
DOi=1TO5
answer = number1 + number2
number1 = number2
number2 = answer
END
RETURN answer
To avoid this kind of problem in an internal function, you can use:
v The PROCEDURE instruction as described in the next topic.
v Different variable names in a function.
Protecting Variables with the PROCEDURE Instruction: When you use the
PROCEDURE instruction immediately following the function label, all variables used
in the function become local to the function and are shielded from the main part of
the exec. You can also use the PROCEDURE EXPOSE instruction to protect all but
a few specified variables.
Writing a Function
80
z/OS V1R1.0 TSO/E REXX User’s 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