Description |
The Continue procedure forces a jump past the remaining statements within a loop, back to the next loop iteration. Like the Goto statement, it should be used with caution.
It is important to note that the Continue statement only jumps to the start of the current loop - not out of any nested loops above it. The Goto statement can.
|
|
Notes |
Use with caution.
|
|
Related commands |
Break |
|
Forces a jump out of a single loop |
For |
|
Starts a loop that executes a finite number of times |
Goto |
|
Forces a jump to a label, regardless of nesting |
Repeat |
|
Repeat statements until a ternmination condition is met |
While |
|
Repeat statements whilst a continuation condition is met |
Abort |
|
Aborts the current processing with a silent exception |
|
|
|
Example code : Skipping loop processing for certain loop values |
var
i : Integer;
s : string;
begin
s := '';
// A big loop
for i := 1 to 9 do
begin // Skip loop processing for certain values of i
if (i = 3) or (i = 7) then Continue;
s := s + IntToStr(i);
s := s + ' ';
end;
// Show the string created by the above loop
ShowMessage('s = '+s);
end;
|
Show full unit code |
s = 1 2 4 5 6 8 9
|
|