TAL Programmer's Guide

Declaring Subprocedures
Structuring Programs
096254 Tandem Computers Incorporated 3–11
Subprocedure Entry Points A subprocedure entry point is an identifier by which callers can call a subprocedure.
The primary entry point is the subprocedure identifier.
Secondary entry points are entry-point identifiers declared within the subprocedure
and then placed at statements where the subprocedure can begin executing. The
following example declares entry-point identifier SUB_ENTRY and places the
identifier at a statement:
PROC myproc;
BEGIN
!Local data declarations
SUBPROC some_sub (param); !Declare subprocedure
INT param;
ENTRY sub_entry; !Declare entry-point
! identifier
INT var;
!Some code here
sub_entry: !Apply entry-point
var := var - param; ! identifier to statement
!More code
END; !End subprocedure
!More subprocedures
!Local statements
CALL sub_entry (1); !Call entry-point SUB_ENTRY
END;
A subprocedure can call an entry-point identifier of any subprocedure within the same
procedure. The caller must pass parameters to the entry-point identifier as if it were
calling the subprocedure identifier. The called subprocedure begins executing at the
location of the entry-point identifier. All the sublocal variables of the called
subprocedure receive their initial values each time the subprocedure is activated.
If you need to reference a subprocedure entry-point identifier before you declare the
subprocedure, a FORWARD declaration is required:
SUBPROC sub_entry (param);
INT param;
FORWARD;