TAL Programmer's Guide
Declaring and Calling Subprocedures
Using Procedures
096254 Tandem Computers Incorporated 11–15
Declaring and Calling
Subprocedures
To declare a subprocedure in its simplest form, specify:
The keyword SUBPROC
The identifier of the subprocedure, followed by a semicolon
A subprocedure body—a BEGIN-END construct that can contain sublocal data
declarations and statements
The following example declares MY_SUBPROC within MY_PROC. A CALL statement
in MY_PROC then calls MY_SUBPROC:
PROC my_proc; !Declare MY_PROC
 BEGIN
 !Declare local data here
 SUBPROC my_subproc; !Declare MY_SUBPROC
 BEGIN
 !Declare sublocal data here
 !Specify sublocal statements here
 END; !End MY_SUBPROC
 !Specify local statements here
 CALL my_subproc; !Call MY_SUBPROC
 END; !End MY_PROC
You can declare FORWARD, VARIABLE, or function subprocedures in the same way
as described for procedures (but inside a procedure).
Including Formal
Parameters
Subprocedures have a 32-word storage area for all sublocal data including variables,
temporary results, parameters, and parameter mask if any. In the following example,
MAIN_PROC contains subprocedures SUB1 and SUB2. MAIN_PROC calls SUB2.
SUB2 calls SUB1 and passes parameters to it:
PROC main_proc MAIN; !Declare MAIN_PROC
 BEGIN
 INT c := 0;
 SUBPROC sub1 (param1); !Declare SUB1
 INT param1; !Declare formal parameter
 BEGIN
 INT a := 5;
 INT b := 2;
 param1 := a + b + c;
 END; !End of SUB1
 SUBPROC sub2; !Declare SUB2
 BEGIN
 INT var := 89;
 CALL sub1 (var); !Call SUB1
 END; !End of SUB2
 CALL sub2;
 END; !End of MAIN_PROC










