IBM SC34-5764-01 Manual page 86

Cics transaction server for vse/esa
Table of Contents

Advertisement

Writing Subroutines and Functions
/******************************* REXX ********************************/
/* This program does not use a PROCEDURE instruction to protect the */
/* variables within its function.
/*********************************************************************/
number1 = 10
SAY pass() number2
EXIT
pass:
number1 = 7
number2 = 5
RETURN number1
Figure 36. Example of Function without the PROCEDURE Instruction
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 or function.
The next example uses PROCEDURE EXPOSE in a subroutine.
/******************************* REXX ********************************/
/* This program 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 the SAY instruction
/* produces this name in uppercase.
/*********************************************************************/
number1 = 10
CALL subroutine
SAY number1 number2
EXIT
subroutine: PROCEDURE EXPOSE number1
number1 = 7
number2 = 5
RETURN
Figure 37. Example Using PROCEDURE EXPOSE in Subroutine
The next example is the same except PROCEDURE EXPOSE is in a function instead of a subroutine.
/******************************* REXX ********************************/
/* This program uses a PROCEDURE instruction with the EXPOSE option */
/* to expose one variable, number1, in its function.
/*********************************************************************/
number1 = 10
SAY pass() number1
EXIT
pass: PROCEDURE EXPOSE number1
number1 = 7
number2 = 5
RETURN number2
Figure 38. Example Using PROCEDURE EXPOSE in a Function
For more information about the PROCEDURE instruction, see section "PROCEDURE" on page 155.
Passing Information by Using Arguments
A way to pass information to either internal or external subroutines or functions is through arguments.
When calling a subroutine, you can pass up to 20 arguments separated by commas on the CALL
instruction as follows:
CALL subroutine_name argument1, argument2, argument3,...
64
CICS TS for VSE/ESA: REXX Guide
/* Produces 7 5 */
/* produces 7 NUMBER2 */
/* Produces 5 7 */
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents