Using the Call Bound Procedure command to pass control

The Call Bound Procedure (CALLPRC) command calls a procedure named on the command, and passes control to it.

The CALLPRC command has the following format:

CALLPRC PRC(procedure-name) PARM(parameter-values) 
RTNVAL(return-value-variable)

The procedure name may not be a variable. When the called procedure finishes running, control returns to the next command in the calling procedure.

Example of using the CALLPRC command

The sequence of CALLPRC commands in a set of procedures calling each other is the call stack. For example, look at this series.

The sequence of CALLPRC commands in a set of procedures calling each other is the call stack example.

In this series, the call stack is as follows.

Call stack example.

When PROGC finishes processing, control returns to PROGB at the command after the call to PROGC. Control is thus returned up the call stack. This occurs whether PROGC ends with a Return (RETURN) or an End Program (ENDPGM) command.

A CL procedure can call itself.