[DUG] {DUG] break procedure

johnkbird at paradise.net.nz johnkbird at paradise.net.nz
Wed Mar 12 19:00:24 NZDT 2008


I stopped at a breakpoint just before the break, and then single stepped (F8)
from there.....it jumped out of the "if" and not the "for".  It either means the
program breaks differently from the help, or the debugger breaks differently
from the program......either is salutory to know.

Quoting Brian Wrigley <bswrigley at xtra.co.nz>:

> Hi John,
> 
> ----- Original Message -----
> From: <johnkbird at paradise.net.nz>
> To: <delphi at listserver.123.net.nz>
> Sent: Wednesday, March 12, 2008 3:15 PM
> Subject: [DUG] {DUG] break procedure
> 
> 
> >
> > 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.
> 
> That's right, it should break from the loop, not just an inner
> begin/end
> controlled by an if statement. Are you sure it's really going into that
> inner block and reaching the break statement? I tried your code snippet
> in
> Delphi 4 (I don't have 5) and it worked as expected, broke right out of
> the
> loop.
> 
> > for i:[=]0 to max [do]
> > 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.
> 
> Maybe the debugger is getting confused about which breaks it put in and
> which ones are yours. What happens if you take out the debugger
> breakpoints
> and put in message boxes instead to show what path is actually being
> taken
> through the code?
> 
> Brian
> 
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>  



John Bird


More information about the Delphi mailing list