Passing Information By Using Arguments - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Writing a Subroutine;
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 subroutine.
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 subroutines is through
arguments. You can pass up to 20 arguments separated by commas on the CALL
instruction as follows:
CALL subroutine_name argument1, argument2, argument3,......
Using the ARG Instruction: The subroutine can receive the arguments with the
ARG instruction. Arguments are also separated by commas in the ARG instruction.
ARG arg1, arg2, arg3, .....
The names of the arguments on the CALL and the ARG instructions do not have to
be the same because information is not passed by argument name but by position.
The first argument sent becomes the first argument received and so forth. You can
also set up a template in the CALL instruction, which is then used in the
corresponding ARG instruction. For information about parsing with templates, see
"Parsing Data" on page 87.
74
z/OS V1R1.0 TSO/E REXX User's Guide
Example Without the PROCEDURE Instruction
/******************************* REXX ******************************/
/* This exec does not use a PROCEDURE instruction to protect the */
/* variables within its subroutine.
/*******************************************************************/
number1 = 10
CALL subroutine
SAY number1 number2
EXIT
subroutine:
number1 = 7
number2 = 5
RETURN
Example Using PROCEDURE EXPOSE
/****************************** REXX *******************************/
/* This exec uses a PROCEDURE instruction with the EXPOSE option to*/
/* expose one variable, number1, in its subroutine. The other
/* variable, number2, is set to null and displays its name in
/* uppercase.
/*******************************************************************/
number1 = 10
CALL subroutine
SAY number1 number2
EXIT
subroutine: PROCEDURE EXPOSE number1
number1 = 7
number2 = 5
RETURN
*/
/* displays 7 5 */
*/
*/
*/
/* displays 7 NUMBER2 */

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents