PROCEDURE statement

A PROCEDURE statement identifies the procedure as a main procedure, a subroutine, or a function. Parameters expected by the procedure and other characteristics are also specified on the PROCEDURE statement.

Read syntax diagramSkip visual syntax diagram
   .--------------.                                         
   V              |                                         
>>---entry-label:-+--PROCEDURE--+-----------------------+------->
                                |   .-,-------------.   |   
                                |   V               |   |   
                                '-(---+-----------+-+-)-'   
                                      '-parameter-'         

>--+----------------+--+------------------+--+-----------+------>
   '-returns-option-'  '-OPTIONS(options)-'  '-RECURSIVE-'   

>--+----------------------------+--+-----------------+--;------->
   '-EXTERNAL(environment-name)-'  '-scope-attribute-'      

   .------------------------.                            
   V                        |                            
>----+-statement----------+-+--END--+-------------+--;---------><
     +-group--------------+         '-entry-label-'      
     +-internal-procedure-+                              
     '-begin-block--------'                              

Abbreviations: PROC for PROCEDURE

entry-label
The entry point to the procedure. External entries are explicitly declared in the invoking procedure. If multiple entry labels are specified, the leftmost name is the primary entry point and is the name returned by the PROCNAME and ONLOC built-in functions. For more information, see Entry data.
parameter
See Parameter attribute and Passing arguments to procedures.
returns-option
Applies only to function procedures. See Functions and RETURNS option and attribute.
OPTIONS option
See OPTIONS option and attribute.
RECURSIVE
See Recursive procedures.
Start of changeEXTERNAL (environment name)End of change
Start of changeIs a scope attribute discussed in Scope of declarations.End of change
scope-attribute
See Scope of declarations.

A procedure (subroutine or function) can have one or more entry points. The primary entry point to a procedure is established by the leftmost label of the procedure statement. Secondary entry points to a procedure are established by additional labels on the PROCEDURE statement and by the ENTRY statement. Each entry point has an entry name. See INTERNAL and EXTERNAL attributes for a discussion of the rules for the creation of an external name.