
To determine whether to make a function internal or external, you might consider
factors, such as:
v
Size of the function. Very large functions often are external, whereas small
functions fit easily within the calling exec.
v
How you want to pass information. It is quicker to pass information through
variables in an internal function. This method is described in the next topic under
“Passing Information by Using Variables”.
v
Whether the function might be of value to more than one exec or user. If so, an
external function is preferable.
v
Performance. The language processor searches for an internal function before it
searches for an external function. For the complete search order of functions,
see “Search Order for Functions” on page 134.
Passing Information to a Function
When an exec and its internal function share the same variables, you can use
commonly shared variables to pass information between caller and internal function.
The function does not need to pass arguments within the parentheses that follow
the function call. However, all functions, both internal and external, must return a
value.
Passing Information by Using Variables
When an exec and its internal function share the same variables, the value of a
variable is what was last assigned, regardless of whether the assignment was in the
main part of the exec or in the function. In the following example, the value of
answer
is assigned in the function and displayed in the main part of the exec. The
variables
number1
,
number2
, and
answer
are shared. In addition, the value of
answer
replaces the function call because
answer
follows the RETURN instruction.
REXX.EXEC(MAIN)
instruction(s)
x=func2(arg1)
instruction(s)
.
.
.
exit
REXX.EXEC(FUNC2)
ARG var1
instruction(s)
RETURN value
Writing a Function
Chapter 6. Writing Subroutines and Functions
79
Содержание TSO/E REXX
Страница 1: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 2: ......
Страница 3: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Страница 10: ...viii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 12: ...x z OS V1R1 0 TSO E REXX User s Guide ...
Страница 14: ...xii z OS V1R1 0 TSO E REXX User s Guide ...
Страница 18: ...xvi z OS V1R1 0 TSO E REXX User s Guide ...
Страница 20: ...2 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 58: ...Tracing Expressions with the TRACE Instruction 40 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 78: ...60 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 86: ...Built In Functions 68 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 128: ...Issuing Other Types of Commands from an Exec 110 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 136: ...Debugging Execs 118 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 170: ...Protecting Elements in the Data Stack 152 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 201: ...Part 3 Appendixes Copyright IBM Corp 1988 2001 183 ...
Страница 202: ...184 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 222: ...Using Variables 204 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 226: ...208 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 238: ...220 z OS V1R1 0 TSO E REXX User s Guide ...
Страница 241: ......