Contents | Index | < Browse | Browse >
PROCEDURE
usage: PROCEDURE [EXPOSE variable [variable...]]
-used with an internal function to create a new symbol table
-the EXPOSE sub-keyword provides a selective mechanism for accessing the
caller's symbol table, and for passing global variables to a function.
The variables following the EXPOSE keyword are taken to refer to
symbols in the caller's table. Any subsequent changes made to these
variables will be reflected in the caller's environment.
-variables in the EXPOSE list may include stem or compound symbols, in
which case the ordering of the variables is significant. The EXPOSE
list is processed from left to right and compound symbols are expanded
based on the values in effect in the new generation (that is, in the
order in which they are activated).
- For example: suppose J in the caller's environment is "123" and J
is uninitialized in the new environment (the procedure). Then,
-PROCEDURE EXPOSE J A.J ---> exposes J and A.123 because J is
"123" in the calling environment
-PROCEDURE EXPOSE A.J J ---> exposes A.J and J

- Exposing a stem has the effect of exposing all possible compound
symbols derived from that stem:
-PROCEDURE EXPOSE A. ---> exposes A.I, A.J, A.J.J, A.123 etc.

Example code:

Var=56.4446
say var
Precision=2
Call Round(var) /* ask function round to two decimal places */
Var=result
say Var
Exit

Round:
procedure expose Precision
/* parse and round number to specified decimal precision */
parse value arg(1)*1.0 with integer '.' fraction
Parse numeric NumDigits .
numeric digits 2
fraction=trunc('.'||fraction,precision)
numeric digits NumDigits
RETURN integer+fraction