The following two examples show the differing results when a function uses the
PROCEDURE instruction and when it doesn’t.
Example Using the PROCEDURE Instruction
/****************************** REXX *******************************/
/* This exec uses a PROCEDURE instruction to protect the variables */
/* within its function. */
/*******************************************************************/
number1 = 10
SAY pass() number2 /* Displays 7 NUMBER2 */
EXIT
pass: PROCEDURE
number1 = 7
number2 = 5
RETURN number1
Example Without the PROCEDURE Instruction
/******************************** REXX *****************************/
/* This exec does not use a PROCEDURE instruction to protect the */
/* variables within its function. */
/*******************************************************************/
number1 = 10
SAY pass() number2 /* displays 7 5 */
EXIT
pass:
number1 = 7
number2 = 5
RETURN number1
Exposing Variables with PROCEDURE EXPOSE: To protect all but specific
variables, use the EXPOSE option with the PROCEDURE instruction, followed by
the variables that are to remain exposed to the function.
Example Using PROCEDURE EXPOSE
/****************************** REXX *******************************/
/* This exec uses a PROCEDURE instruction with the EXPOSE option to*/
/* expose one variable, number1, in its function. */
/*******************************************************************/
number1 = 10
SAY pass() number1 /* displays 5 7 */
EXIT
pass: PROCEDURE EXPOSE number1
number1 = 7
number2 = 5
RETURN number2
For more information about the PROCEDURE instruction, see z/OS TSO/E REXX
Reference.
Passing Information by Using Arguments
A way to pass information to either internal or external functions is through
arguments. You can pass up to 20 arguments separated by commas in a function
call.
Writing a Function
Chapter 6. Writing Subroutines and Functions 81