PROCEDURE
Purpose
PROCEDURE
EXPOSE name
(name)
;
PROCEDURE, within an internal routine (subroutine or function), protects variables by making them
unknown to the instructions that follow it. After a RETURN instruction is processed, the original variables
environment is restored and any variables used in the routine (that were not exposed) are dropped. (An
exposed variable is one belonging to a caller of a routine that the PROCEDURE instruction has exposed.
When the routine refers to, or alters, the variable, the original (caller's) copy of the variable is used.) An
internal routine need not include a PROCEDURE instruction; in this case the variables it is manipulating
are those the caller “owns.” If used, the PROCEDURE instruction must be the first instruction processed
after the CALL or function invocation; that is, it must be the first instruction following the label.
If you use the EXPOSE option, any variable specified by name is exposed. Any reference to it (including
setting and dropping) refers to the variables environment the caller owns. Hence, the values of existing
variables are accessible, and any changes are persistent even on RETURN from the routine. If name is
not enclosed in parentheses, it identifies a variable you want to expose and must be a symbol that is a
valid variable name, separated from any other name with one or more blanks.
If parentheses enclose a single name, then, after the variable name is exposed, the value of name is
immediately used as a subsidiary list of variables. (Blanks are not necessary either inside or outside the
parentheses, but you can add them if desired.) This subsidiary list must follow the same rules as the
original list (that is, valid variable names, separated by blanks) except that no parentheses are allowed.
Variables are exposed in sequence from left to right. It is not an error to specify a name more than one
time, or to specify a name that the caller has not used as a variable.
Any variables in the main program that are not exposed are still protected. Therefore, some limited set of
the caller's variables can be made accessible, and these variables can be changed (or new variables in
this set can be created). All these changes are visible to the caller upon RETURN from the routine.
PROCEDURE
Chapter 13. Keyword Instructions 155