Continue Statements

The continue flow control statement breaks out of the current iteration of a loop and lets execution resume with the next iteration of the loop, presuming there are further iterations left to complete.

var i := 0;
while i < 30 do begin
  i := i + 1;
  if i = 15 then continue; // skip the following code for "15" only
  writeLn(i);
end;

Labeled Loops

If the loop is labeled with a name, that name can be used alongside break to be more explicit about which loop to beak out of. This is especially helpful when using nested loops:

var i := 0;
lOuterLoop: while i < 30 do begin
  i := i + 1;
  for j := 0 to 20 do begin
    if i*j = 150 then continue lOuterLoop; // continue the OUTER loop
    writeLn(i*j);
  end
  writeLn(i);
end;

See Also