pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-13
Labels as Procedure Parameters
Labels as Procedure Parameters
TAL
You can declare a formal parameter to be a label, pass a label to the procedure when
you call it, and use a GOTO statement to branch to the label parameter from the called
procedure.
In Example 15-17 on page 15-13, when p1 executes the statement GOTO label_a,
parameters and local variables that were pushed onto the stack for procedure p1 are
popped, and control transfers immediately to label_b in p2.
pTAL
In Example 15-17 on page 15-13, LABEL is an invalid data type for a formal parameter.
The declaration of label_a in p1 is invalid. Also, you cannot pass a label as an actual
parameter. The parameter label_b in the call to procedure p1 in procedure p2 is
invalid.
Example 15-17. Labels as Procedure Parameters (TAL)
PROC p1 (label_a); ! Procedure with label parameter
LABEL label_a;
BEGIN
GOTO label_b; ! Go to label label_b in procedure p2
END;
PROC p2;
BEGIN
...
CALL p1 (label_b); ! Call p1 passing label_b as a parameter
label_b: ! Establish actual location of label_b
...
END;