TAL Reference Manual

Procedures
TAL Reference Manual526371-001
13-18
Example of Subprocedure Declaration
Sublocal Variables
In subprocedures, declare pointers and directly addressed variables only. Here are
examples:
If you use an indirection symbol (. or .EXT) with sublocal arrays and structures, the
compiler allocates them as direct arrays and structures and issues a warning.
Because each subprocedure has only a 32-word area for variables, declare large
arrays or structures at the global or local level and make them indirect.
Example of Subprocedure Declaration
This example declares a function subprocedure:
PROC myproc;
BEGIN
INT result;
INT SUBPROC mult (var1, var2); !Declare function
INT var1, var2; ! subprocedure
BEGIN
RETURN var1 * var2;
END; !End subprocedure
result := mult(2, 3);
END;
Entry-Point Declaration
The entry-point declaration associates an identifier with a secondary location in a
procedure or subprocedure where execution can start.
Sublocal Variable Example
Simple variable (which are always
direct)
INT var;
Direct array
INT array[0:5];
Read-only array
INT ro_array = 'P' :=
[0,1,2,3,4,5];
Direct structure
STRUCT struct_a;
BEGIN
INT a, b, c;
END;
Simple pointer
INT .simple_ptr;
Structure pointer
STRING .struct_ptr (struct_a);