Procedures

A procedure is a sequence of statements delimited by a PROCEDURE statement and a corresponding END statement. A procedure can be a main procedure, a subroutine, or a function.

An application must have exactly one external procedure that has OPTIONS(MAIN). In the following example, the name of the procedure is Name and represents the entry point of the procedure.

  Name:
     procedure;
  end Name;

The ENTRY statement can define a secondary entry point to a procedure. Consider the following example:

  Name: procedure;
  B: entry;
  end Name;

B defines a secondary entry point to the Name procedure. The ENTRY statement is described in ENTRY attribute.

A procedure must have a name. A procedure block nested within another procedure or begin-block is called an internal procedure. A procedure block not nested within another procedure or begin-block is called an external procedure. Level-1 exported procedures from a package also become external procedures. External procedures can be invoked by other procedures in other compilation units. Procedures can invoke other procedures.

A procedure can be recursive, which means that it can be reactivated from within itself or from within another active procedure while it is already active. You can pass arguments when invoking a procedure.