Directives
CALL Transfer to Subprogram
   
Format CALL subprog$[;entry$][,ERR=stmtref][,arglist...]
 
Where:
;entry$ Name of starting statement 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 statement label to which to transfer control.
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 received in the called subprogram for its use via the ENTER directive.

The called program should terminate with an EXIT, which may be replaced by an END or STOP.

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

Pass a complete array to a subprogram by specifying the array name followed by {ALL}. In this case, all values are passed to the subprogram and any changes made are returned to the calling program. See the ProvideX User's Guide for more details on this directive.

String templates cannot be passed if they are defined prior to the ENTER statement in the called program.

CALL Using Entry-Point Labels

This directive also has an optional ProvideX feature you'll find useful for applications like subprogram "libraries" (with multiple stand-alone routines, each accessed by a statement label). To use this form of access, append a semicolon plus the label name of the starting statement to the subprogram name (e.g., CALL "PROG;STARTING_LABEL",ERR=1000,X$,A,CT$). After the called subprogram is loaded, ProvideX internally issues a GOTO STARTING_LABEL (e.g.) directive and starts execution there. Use this to create a single subprogram with multiple entry points and ENTER directives.

In addition, PxPlus allows the specification of a line number instead of a label. To specify a line number, the entry point must consist of a pound sign (#) followed by the line number. (e.g. CALL "ProgABC;#1000" would start execution at statement 1000 in ProgABC).

  Specifying a line number as an entry point is an +PxPlus Exclusive

CALL and ENTER from ASCII Programs

When you run programs from ASCII text files, the CALL and ENTER with no arguments will always fail because the system thinks that the variables have already been assigned. To work around this, use the PERFORM directive or save the called program in a program file.

   
See Also ENTER Specify Arguments
PERFORM Call Subprogram, Pass Variables
END Halt Execution of Program
EXIT Terminate Subprogram and Return
STOP Halt Program Execution.
   
Examples

0020 CALL "ABCDEF",ERR=0050,A,4*F,Z$,X$(4,5),(Q)

In ABCDEF:

0030 ENTER Z,X,A$,B$,V$

Z will receive the value of A – A will reflect changes in Z.
X will receive the value of 4*F.
A$ will receive the value of Z$ – Z$ will reflect changes in A$. B$ will receive the string from X$(4,5)which will not change. V$ will receive Q$ but Q$ cannot be changed.