pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-24
Nonlocal
Nonlocal
If the GOTO statement is in a subprocedure and the target statement is in the
enclosing procedure, the GOTO statement is nonlocal.
GOTO and Target Statements With Different Trapping States
A GOTO statement, local or nonlocal, must have the same trapping state as its target
statement.
Note. Nonlocal GOTO statements are are inefficient and not recommended.
Example 12-22. Nonlocal GOTO Statement
int global_var;
proc p;
begin
int i;
label L1;
int subproc s (x);
int (x);
begin
label L2:
if x = 0 then goto L1; ! Nonlocal goto
if x > 10 goto L2; ! Local goto
return 1;
L2: return x;
end;
i := s (global_var);
if i <> 1 then goto L1; ! Local goto
! Processing occurs here
L1:
end;
Example 12-23. Local GOTO and Target Statements That Have Different Trapping
States
proc p nooverflow_traps;
begin
subproc s overflow_traps;
begin
goto L1; ! Illegal trapping states differ
end;
L1:
end;