TAL Programmer's Guide

Using Procedure Options
Using Procedures
096254 Tandem Computers Incorporated 11–7
Returning From
a Procedure
A called procedure returns control to the caller when a RETURN statement is executed
or the last END keyword is reached. (In a nonfunction procedure, a RETURN
statement is optional.) In the following example, MY_PROC returns control when A is
less than B, which invokes the RETURN statement, or when the last END is reached:
PROC my_proc;
BEGIN
INT a, b;
!Lots of code
IF a < b THEN
RETURN; !Return to caller if A < B
!Lots more code
END; !Last END keyword
Using Procedure
Options
By specifying procedure declaration options, you can declare:
The MAIN procedure
Functions
FORWARD procedures
EXTERNAL procedures
VARIABLE procedures
EXTENSIBLE procedures
Other procedure declaration options include:
Public name and LANGUAGE options, described in Section 17, “Mixed-Language
Programming.”
INTERRUPT, RESIDENT, CALLABLE, and PRIV options, described in the TAL
Reference Manual. Most of these options are used only by system procedures.
Declaring the
MAIN Procedure
An executable program requires a MAIN procedure. It is the first procedure executed
when you run the program (although it often appears last.) The MAIN procedure
cannot have parameters. If more than one MAIN procedure appears in a program, the
compiler issues a warning and uses the first one it encounters as the MAIN procedure.
When the MAIN procedure completes execution, it passes control to the
PROCESS_STOP_ system procedure, rather than executing an EXIT instruction.
To declare the MAIN procedure, include the MAIN keyword following the procedure
identifier:
PROC mymain MAIN; !Declare MAIN procedure
BEGIN
!Lots of code
CALL some_procedure;
END;