| Directives |
|
| Format | CALL
subprog$[;entry$][,ERR=stmtref][,arglist...] Where:
|
||||||||
| 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. 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
|
||||||||
| *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.,
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. 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).
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 |
In ABCDEF:
Z will receive the value
of A A will reflect changes in Z. |