Name

Break Procedure

Syntax

Break;

Description

Break jumps out of a loop, similar to the following goto statement:

label BreakOut;
begin
  while Condition do
  begin
    DoSomething;
    if AnotherCondition then
      goto BreakOut;  // like Break;
  end;
 BreakOut:
  // Controls transfer to the statement after the loop

If you call Break from within nested loop statements, control transfers out of the innermost loop only. To break out of multiple loops at one time, you must use a goto statement.

Break is not a real procedure, but is handled specially by the compiler. If you try to use Break outside of a loop statement, the compiler issues an error message.

See Also

Continue Procedure, Exit Procedure, For Keyword, Repeat Keyword, While Keyword

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.