NET/MASTER Network Control Language (NCL) Programmer's Guide

Single and Repetitive Execution
Controlling Execution Flow
106160 Tandem Computers Incorporated 5–21
Using Labels on a DO
Statement
You can specify one or more labels on a DO statement. The END statement that closes
the DO can specify the label (or one of the labels if more than one) to allow the
compiler to check statement nesting for you. Specifying labels can be helpful when
you nest DO loops to ensure that you match the opening DO statement with the
correct closing END statement. The following example shows two DO loops with
labels:
zex0514n: PROCEDURE
/* Nested DO loop */
label1: DO 2
SAY OUTER LOOP
label2: DO &control = 1 to 5
SAY Inner loop pass &control
END label2
END label1
END zex0514n
Iterating and Leaving a DO
Loop
Loops continue to execute as long as some condition is satisfied. The ITERATE and
LEAVE core statements allow you to control whether the condition is met according to
the evaluation of some other condition.
The ITERATE Core Statement
The ITERATE core statement performs the next iteration of a repetitive DO loop. The
ITERATE statement logically passes control to the bottom (the END statement) of a
DO loop.
If you do not specify a target label after the ITERATE statement, ITERATE passes
control to the END statement at the bottom of the DO loop in which the ITERATE
statement is executed. If you do specify a target label, the ITERATE statement
searches for the label. If you specify a label after the ITERATE statement, it must be
constant.