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 = n 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
DO i = 1 TO 5
SAY add()
/* Displays 105 */
END
EXIT
add:
DO i = 1 TO 5
answer = n 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
Содержание 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: ......