Chapter 18. Procedure Specifications

Procedure specifications are used to define prototyped procedures that are specified after the main source section, otherwise known as subprocedures.

The prototype for the subprocedure may be defined in the main source section of the module containing the subprocedure definition. If the prototype is not specified, the prototype is implicitly defined using the information in the procedure interface. If the procedure interface is also not defined, a default prototype with no return value and no parameters is implicitly defined.

A subprocedure includes the following:

  1. A Begin-Procedure specification (B in position 24 of a procedure specification)
  2. A Procedure-Interface definition, which specifies the return value and parameters, if any. The procedure-interface definition is optional if the subprocedure does not return a value and does not have any parameters that are passed to it. The procedure interface must match the corresponding prototype, if the prototype is specified.
  3. Other definition specifications of variables, constants and prototypes needed by the subprocedure. These definitions are local definitions.
  4. Any calculation specifications needed to perform the task of the procedure. Any subroutines included within the subprocedure are local. They cannot be used outside of the subprocedure. If the subprocedure returns a value, then a RETURN operation must be coded within the subprocedure. You should ensure that a RETURN operation is performed before reaching the end of the procedure.
  5. An End-Procedure specification (E in position 24 of a procedure specification)

Except for a procedure-interface definition, which may be placed anywhere within the definition specifications, a subprocedure must be coded in the order shown above.

For an example of a subprocedure, see Figure 5.



[ Top of Page | Previous Page | Next Page | Contents | Index ]