TAL Programmer's Guide

GOTO Statement
Controlling Program Flow
12–24 096254 Tandem Computers Incorporated
GOTO Statement The GOTO statement unconditionally transfers program control to the statement that
is preceded by the specified label.
To specify a GOTO statement, include a label identifier after the GOTO keyword; for
example:
GOTO label_one;
Local Scope A local GOTO statement can refer only to a local label in the same procedure. A local
GOTO statement cannot refer to a label in a subprocedure or in any other procedure.
In the following example, a local GOTO statement branches to a local label:
PROC p
BEGIN
LABEL calc_a; !Declare local label
INT a;
INT b := 5;
calc_a : !Place label at local statement
a := b * 2;
!Lots of code
GOTO calc_a; !Local branch to local label
END;
Sublocal Scope A sublocal GOTO statement can refer to a label in the same subprocedure or in the
encompassing procedure. A sublocal GOTO statement cannot refer to a label in
another subprocedure.
In the following example, a sublocal GOTO statement branches to a local label:
PROC p;
BEGIN
LABEL a; !Declare local label
INT i;
SUBPROC s;
BEGIN
!Lots of code
GOTO a; !Sublocal branch to local label
END;
!Lots of code
a : !Place label at local statement
i := 0;
!More code
END;