ENTRY statement

The ENTRY statement specifies a secondary entry point of a procedure. The ENTRY statement must be internal to the procedure for which it defines a secondary entry point. It cannot be within a do-group that specifies repetitive execution, or internal to a ON-unit.

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

>--+----------------------------+------------------------------->
   '-EXTERNAL(environment-name)-'   

>--+--------------------------+--+------------------+--;-------><
   |          .-----------.   |  '-OPTIONS(options)-'      
   |          V           |   |                            
   '-RETURNS(---attribute-+-)-'                            

entry-label
The secondary entry point to the procedure.
parameter
See Parameter attribute and Passing arguments to procedures.
EXTERNAL (environment name)
Is a scope attribute discussed in Scope of declarations.
RETURNS option
See RETURNS option and attribute.
OPTIONS option
See OPTIONS option and attribute.

All parameters on an ENTRY statement must be BYADDR, and for a procedure containing ENTRY statements, all non-pointer parameters to that procedure must be BYADDR.

If a procedure containing ENTRY statements has the RETURNS option (or if any of its contained ENTRY statements have the RETURNS option), then:
  • The BYADDR attribute must be specified (or implied by the compile-time option DEFAULT(RETURNS(BYADDR)) in all of the RETURNS options for that procedure and its ENTRY statements.
  • All routines that call one of these entry points must also either declare the entry with RETURNS(BYADDR) or be compiled with the DEFAULT(RETURNS(BYADDR)) compiler option.
When a procedure contains ENTRY statements and some, but not all of its entry points have the RETURNS attribute, the ERROR condition is detected under the following circumstances:
  • If the code executes a RETURN statement with an expression when the procedure was entered at an entry point which did not have the RETURNS attribute.
  • If the code executes a RETURN statement without an expression when the procedure was entered at an entry point that has the RETURNS attribute.