Subroutines and Functions—Similarities and Differences
The following tables highlight similarities and differences between subroutines and functions:
Similarities between Subroutines and Functions
Can be internal or external.
Internal
– Can pass information by using common variables
– Can protect variables with the PROCEDURE instruction
– Can pass information by using arguments.
External
– Must pass information by using arguments
– Can use the ARG instruction or the ARG built-in function to receive arguments.
Uses the RETURN instruction to return to the caller.
Differences between Subroutines and Functions
Subroutines Functions
Calling Call by using the CALL instruction, followed
by the subroutine name and, optionally, up to
20 arguments.
Call by specifying the function's name,
immediately followed by parentheses that
optionally contain up to 20 arguments.
Returning a Value Might return a value to the caller. If you
include a value on the RETURN instruction,
the language processor assigns this value to
the REXX special variable RESULT.
Must return a value. Specify a value on the
RETURN instruction; the language processor
replaces the function call with this value.
Writing Subroutines and Functions
70
CICS TS for VSE/ESA: REXX Guide