pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
14 Procedures, Subprocedures, and Procedure Pointers
Procedures are program units that contain the executable portions of a pTAL program and that are
callable from anywhere in the program. Procedures allow you to segment a program into discrete
parts that each perform a particular task such as I/O or error handling.
An executable program contains at least one procedure. One procedure in the program has the
attribute MAIN, which identifies it as the first procedure to execute when you run the program.
A procedure can contain subprocedures, which are callable from various points within the same
procedure.
A function is a procedure or subprocedure that returns a value. A function is also known as a typed
procedure or typed subprocedure.
Topics:
• Procedure Declarations (page 246)
• Procedure Attributes (page 248)
• Formal Parameter Specification (page 251)
• Procedure Body (page 256)
• Subprocedure Declarations (page 257)
• Subprocedure Body (page 259)
• Entry-Point Declarations (page 260)
• Procedure Pointers (page 263)
• Labels in Procedures (page 273)
In this section, references to procedures refers to procedures and subprocedures unless otherwise
specified.
Procedure Declarations
A procedure is a program unit that is callable from anywhere in the program. You declare a
procedure as follows:
type
specifies that the procedure is a function that returns a result and indicates the data type of the
returned result. type can be any data type described in Chapter 3 (page 46).
identifier
is the procedure identifier to use in the compilation unit.
246 Procedures, Subprocedures, and Procedure Pointers