| Directives |
|
| Format | PERFORM
prog$ [,DOM=nolabelref]
[,ERR=stmtref] Where:
|
|||||||||||||||||
| Description | The PERFORM directive saves the current program state, then transfers control to a subprogram. All variables are made common between the initiating program and the subprogram. When the subprogram terminates, control returns to the initiating program at the directive following the PERFORM directive. | |||||||||||||||||
| *Note* | All variables that are changed or created during execution of the performed subprogram will be returned to the initiating program. | |||||||||||||||||
| You
can specify an optional entry point in the subprogram. To
do this, append a semicolon and the starting label name
(;entry$) to the subprogram name; e.g., PERFORM
"SUBPROG;STARTING_LABEL". After the subprogram
is loaded, ProvideX internally issues a GOTO
directive using the label as a statement reference and
starts execution there. Use this feature to create
subprograms to act as "libraries" (i.e.,
multiple stand-alone routines, each starting at its own
entry point). 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. PERFORM "SubProg;#1000" would start at statement 1000 in SubProg). The execution of the subprogram is normally terminated with an EXIT, however, the END or STOP directives may be used in its place. Subroutine within a Subprogram PERFORM can also access subroutines externally via entry points in the called program. In this case, the RETURN statement that is used to terminate the subroutine in a subprogram will automatically return control to the initiating program. This feature allows the same chunk of code to be accessed internally (GOSUB) as well as externally (PERFORM). |
||||||||||||||||||
| Null String | If
desired a NULL string may be passed to the PERFORM. This
will cause nothing to be executed -- effectively the
PERFORM becomes a comment. This feature allows
applications to include logical option "Exit
Points" within their application where the exit
point can be assigned to a variable that, if set, causes
the application to run logic from an external program. This capability can be disabled using the '+N' System Parameter
|
|||||||||||||||||
| See Also | CALL
Transfer to Subprogram, RUN Transfer and Execute a Program END Halt Execution of Program EXIT Terminate Subprogram and Return STOP Halt Program Execution GOSUB.. Execute Subroutine RETURN Return From a Subroutine |
|||||||||||||||||
| Example | This
is the calling program:
This is the subprogram:
|
|||||||||||||||||