pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-23
GOTO
GOTO
The GOTO statement unconditionally transfers control to a labeled target statement.
label-name
is the label that precedes the target statement (see Labels in Procedures on
page 14-37).
A GOTO statement can be either local or nonlocal.
Topics:
Local on page 12-23
Nonlocal on page 12-24 (not recommended)
GOTO and Target Statements With Different Trapping States on page 12-24
Local
If the GOTO statement and the target statement are in the same procedure or in the
same subprocedure, the GOTO statement is local.
INT PROC p2; ! p2 has optimized FOR statement
BEGIN
USE i;
y := 0;
FOR i := 1 to q() DO ... ; ! q is called 1 time
! i=10 here
RETURN x; ! p2 returns 1
END;
Example 12-21. Local GOTO Statement
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;
Example 12-20. Standard and Optimized FOR Statements (page 2 of 2)
VST049.vsd
GOTO label-name