40
CALL Directive
Transfer to Subprogram
Format
CALL subprog$[;entry$][,ERR=stmtref][, arglist]
Where:
;entry$
Name of starting line label to use as entry point in the subprogram.
Optional. Max string size 8kb. If included, use a leading semicolon and
add it to the subprog string expression; e.g.,
CALL "get_pizza;order",top_1,top_2 ...
arglist
Comma-separated list of variables, literals, or expressions.
stmtref
Program line number or label to transfer control to.
subprog$ Name of the subprogram to call. Max string size 8kb.
Description
Use the CALL directive to transfer control to a subprogram. The current program state is
saved and the specified subprogram is loaded and executed. If you use arguments, they
are recieved in the called subprogram via the ENTER directive.
The called program should terminate with an EXIT, which may be replaced by an END
Arguments for CALL and ENTER
Normally, the total number of arguments in the CALL and ENTER statements must
match. Each argument in the CALL statement must correspond in relative position
and in type (numeric or string) to a variable in the ENTER statement. If you use a
shorter list of arguments in a CALL statement than in the ENTER statement, make
sure to maintain relative position and type up to the point where you shorten the list
(and include error handling options). Otherwise, ProvideX returns
Error #36: ENTER parameters don't match those of the CALL.
Warning: If you pass an argument to the subprogram using a simple variable (e.g.,
A$,Z) then any changes to the variable in the subprogram will have an effect in the
calling program. Subscripted variables/expressions (including substrings) or any
values enclosed in parentheses only have their values passed one way: to the
subprogram. Changes made to these will not affect the calling program.
You can protect a simple variable in a CALL or ENTER statement by placing it inside
parentheses. This turns the variable into an expression, which has the effect of
making it read only; e.g., CALL "PROG",(A$).
IOLists can also be used as arguments for CALL statements; e.g.,
CALL "PROG",IOL=8000