TAL Programmer's Guide

Declaring Procedures
Structuring Programs
096254 Tandem Computers Incorporated 3–7
EXTERNAL Procedures If you want to call a procedure that is compiled in another compilation unit, first
declare a procedure heading that includes the EXTERNAL keyword. Once you
declare an EXTERNAL procedure, you can call the procedure from anywhere in the
current compilation unit. For example, you can declare an EXTERNAL procedure
named FARAWAY like this:
PROC faraway;
EXTERNAL;
Procedure Entry Points A procedure entry point is an identifier by which callers can call a procedure. The
primary entry point is the procedure identifier.
Secondary entry points are entry-point identifiers declared within the procedure and
then placed at statements where the procedure can begin executing. The following
example declares entry-point identifier ENTRY1 and places the identifier at a
statement:
PROC myproc (param); !Declare the procedure
INT param;
BEGIN
ENTRY entry1; !Declare entry-point
! identifier
INT var;
!Some code here
entry1: !Apply entry-point
var := var - param; ! identifier to statement
!More code
END;
Any procedure or subprocedure in the compilation unit can call an entry-point
identifier. The caller must pass parameters as if the procedure identifier were being
called. The called procedure begins executing at the location of the entry-point
identifier. At each activation of an entry-point identifier, all local variables receive
their initial values.
The FORWARD declaration for the preceding ENTRY1 entry point is:
PROC entry1 (param);
INT param;
FORWARD;
The EXTERNAL declaration for the ENTRY1 entry point is:
PROC entry1 (param);
INT param;
EXTERNAL;