Previous Topic Next topic Print topic


Calls and Returns

Statements within a procedure block are executed only when the procedure block is called from another procedure block. The CALL statement enables procedure calling. For example:

A: PROCEDURE;
      .
      .
      . 
   CALL B;
      .
      .
      .
B: PROCEDURE;
      .
      .
      . 
   END B;
      .
      .
      .
   END A;

In this example, procedure B is executed only when it is called from procedure A. Procedure A resumes execution at the statement following the call when B is completed.

A procedure returns to its caller either by executing its END statement or by executing a RETURN statement, as shown in the following example:

A: PROCEDURE;
      .
      .
      .
   IF X<0 THEN RETURN;
      .
      .
      .
   END A;

Control does not "flow" into a procedure; that is, if control reaches a statement immediately preceding a procedure declaration, then (unless the statement is a control-flow statement such as GOTO) control will automatically skip to the statement following the declared procedure.

Previous Topic Next topic Print topic