z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Protecting Variables with the PROCEDURE Instruction

z/OS TSO/E REXX User's Guide
SA32-0982-00

When you use the PROCEDURE instruction immediately after the subroutine label, all variables used in the subroutine become local to the subroutine 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.

The following two examples show the differing results when a subroutine 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 subroutine.                                          */
/*******************************************************************/
 number1 = 10
 CALL subroutine
 SAY number1 number2                      /* displays  10  NUMBER2 */
 EXIT

 subroutine: PROCEDURE
 number1 = 7
 number2 = 5
 RETURN

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                             /* displays 7  5  */
 EXIT

 subroutine:
 number1 = 7
 number2 = 5
 RETURN

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014