[DUG] {DUG] break procedure

johnkbird at paradise.net.nz johnkbird at paradise.net.nz
Wed Mar 12 15:15:40 NZDT 2008


I have been taken by surprise by the break statement - all help says clearly it
should exit the current for/while/repeat loop.  I have a block with an "if"
block inside a "for" block where break does something different.


for i:0 to max
begin
  .
  .
  .
  if SomeCondition then
  begin
    do_something
    break;
  end
  //end of if
  //more statements executed if did not break out of loop
  .                <=== break jumps to here
  .
  .
end

in case the above example gets garbled by the email send, the break jumps  out
of the "if" loop only, not out of the enclosing "for" loop.   The help says it
should have jumped out of the "for" loop altogether....

This is the D5 debugger.

Can anyone shed light?

If I cannot know for certain where control goes this could break a bit of my
code as I do rely on it.

[thinks - I could always use a "goto  label" - bring back the good old days eh!]


John



More information about the Delphi mailing list