break statement breaks out of the current loop and lets execution resume on the first statement after the loop, forgoing any further iterations.
var i := 0; loop begin i := i + 1; if i = 15 then break; // exit the loop when we hit 15 end;
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: loop begin i := i + 1; for j := 0 to 20 do begin if i*j = 150 then break lOuterLoop; // exit the OUTER loop end end;