TAL Programmer's Guide

Formatting Programs
Structuring Programs
3–16 096254 Tandem Computers Incorporated
Formatting With
BEGIN-END Constructs
You use BEGIN-END constructs to group various items into a single entity. If you
align the BEGIN and END keywords vertically, the program is easier to understand.
Following are some uses for BEGIN-END constructs.
Procedure or Subprocedure Body
Within a procedure (or subprocedure) declaration, enclose the procedure (or
subprocedure) body in a BEGIN-END construct:
PROC add;
BEGIN
!Procedure body
END;
Structure Layout
Within a structure declaration, enclose the structure layout in a BEGIN-END construct:
STRUCT inventory;
BEGIN
!Structure item
!Structure item
!Structure item
END;
Compound Statements
Place a compound statement in a BEGIN-END construct. A compound statement
consists of multiple statements you want treated as a single logical statement:
BEGIN
!Statement
!Statement
!Statement
END;
For example, you can specify a choice of compound statements in an IF statement as
follows:
IF a < b THEN
BEGIN !Begin compound statement
a := 1;
b := 2;
c := a + b;
END !End compound statement
ELSE
BEGIN !Begin compound statement
a := 5;
b := 6;
c := a + b;
END; !End compound statement