Delphi Compiler Error
E2097 BREAK or CONTINUE outside of loop
Reason for the Error & Solution
The compiler has found a BREAK or CONTINUE statement which is not contained inside a WHILE or REPEAT loop. These two constructs are only legal in loops.
program Produce; procedure Error; var i : Integer; begin i := 0; while i < 100 do INC(i); if odd(i) then begin INC(i); continue; end; end; begin end.
The example above shows how a continue statement could seem to be included in the body of a looping construct but, due to the compound-statement nature of The Delphi language, it really is not.
program Solve; procedure Error; var i : Integer; begin i := 0; while i < 100 do begin INC(i); if odd(i) then begin INC(i); continue; end; end; end; begin end.
Often times it is a simple matter to create compound statement out of the looping construct to ensure that your CONTINUE or BREAK statements are included.