statement is used to complete execution of one of the iterations of
an enclosing loop statement. The completion is conditional if the
statement includes a condition.
next loop_label when condition;
The next statement allows to
skip a part of an iteration loop. If the condition specified after
the when reserved word is
TRUE, or if there is no condition at all, then the statement is
executed. This results in skipping all statements below it until the
end of the loop and passing the control to the first statement in the
next iteration (example 1).
A next statement may specify
the name of the loop it is expected to influence. If no label is
supported then the statement applies to the innermost enclosing loop
count_value in 1 to
Assign_1: A(count_value) := '0';
next when condition_1;
Assign_2: A(count_value + 8) := '0';
end loop Loop_Z;
If the condition_1 in the iteration count_value is TRUE, then the
next statement will be executed. The next statement to be executed
will be Assign_1 in the iteration count_value+1. Otherwise, the
sequence of operations is as specified, i.e. Assign_2 is executed.
Loop_X: for count_value in
1 to 8 loop
A(count_value) := '0';
B(k) := '0';
Loop_X when condition_1;
B(k + 8) := '0';
:= k + 1;
end loop Loop_Y;
end loop Loop_X;
If condition_1 is TRUE,
then the next statement is executed and the control goes to the
assignment statement labeled Assign_1
in the next iteration of Loop_X.
If not, then the iteration is continued with Assign_3,
causing incrementing k.
The next statement is often
confused with the exit
statement. The difference between the two is that the exit
statement "exits" the loop entirely, while the next
statement skips to the "next" loop iteration (in
other words, it "exits" the current iteration of the loop).