TAL Programmer's Guide

Using Labels
Using Procedures
11–48 096254 Tandem Computers Incorporated
Using Labels Within a procedure, you can declare labels for use within the same procedure. Labels
have local or sublocal scope only.
Labels are the only declarable objects that you need not declare before using them. For
best program management, however, declare all labels.
Using Local Labels To declare and use local labels:
1. Declare the label identifier inside a procedure (in the local declarations) by
specifying the keyword LABEL and the label identifier; for example:
LABEL loc_label; !Declare LOC_LABEL
2. Place the label identifier and a colon (:) preceding a statement in the same
procedure (but not in a subprocedure); for example:
loc_label: !Use the label for
a := 5; ! this statement
3. Reference the label in a GOTO statement located in the same procedure or in any
subprocedure contained in that procedure.
You can branch to local labels by using local or sublocal GOTO statements in the same
procedure. In the following example, a local GOTO statement references a local label:
INT op1, op2, result; !Declare global data
PROC p;
BEGIN
LABEL addr; !Declare label ADDR
op1 := 5;
op2 := 28;
addr: !Use label ADDR for
result := op1 + op2; ! this statement
op1 := op2 * 299;
!More code
IF result < 100 THEN
GOTO addr; !Branch to label ADDR
END;