IBM SC34-5764-01 Manual page 83

Cics transaction server for vse/esa
Table of Contents

Advertisement

/******************************* REXX ********************************/
/* This program receives a calculated value from an internal
/* subroutine and uses that value in a SAY instruction.
/*********************************************************************/
number1 = 5
number2 = 10
CALL subroutine
SAY answer
EXIT
subroutine:
answer = number1 + number2
RETURN
Figure 29. Example of Passing Information in a Variable Using a Subroutine
The next example is the same, except it passes information to a function rather than a subroutine. The
subroutine includes the variable answer on the RETURN instruction. The language processor replaces the
function call with the value in answer.
/******************************* REXX ********************************/
/* This program receives a calculated value from an internal
/* function and uses SAY to produce that value.
/*********************************************************************/
number1 = 5
number2 = 10
SAY add()
SAY answer
EXIT
add:
answer = number1 + number2
RETURN answer
Figure 30. Example of Passing Information in a Variable Using a Function
Using the same variables in a program and its internal subroutine or function can sometimes create
problems. In the next example, the main part of the program and the subroutine use the same control
variable, i, for their DO loops. As a result, the DO loop runs only once in the main program because the
subroutine returns to the main program with i = 6.
/* Produces 15 */
/* Produces 15 */
/* Also produces 15 */
Writing Subroutines and Functions
*/
*/
*/
*/
Chapter 6. Writing Subroutines and Functions
61

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents