Next: , Previous: LE, Up: Reference



Leave

Synopsis

     Leave  { simple statement }

Description

With Leave you can exit the body of the current loop instantly. It can only be used within a while, repeat or a for loop.

Conforming to

Leave is a Mac Pascal extension. Borland Pascal has Break instead.

Example

     program LeaveDemo;
     var
       Foo: Integer;
     begin
       while True do
         begin
           repeat
             WriteLn ('Enter a number less than 100:');
             ReadLn (Foo);
             if Foo < 100 then
               Leave;  { Exits `repeat' loop }
             WriteLn (Foo, ' is not exactly less than 100! Try again ...')
           until False;
           if Foo > 50 then
             Leave;  { Exits `while' loop }
           WriteLn ('The number entered was not greater than 50.')
         end
     end.

See also

Loop Control Statements, Break, Continue, Cycle, Exit, Halt, Return, goto.