Infinite loop

This is an old revision of Infinite loop, edited by Djzepi at . The current revision is 112623.

Created page with "{{Infinite loop}} An infinite loop (also known as an endless loop or unproductive loop or a continuous loop) is a loop which never ends. Inside loop, statements are repeated ..."

An infinite loop (also known as an endless loop or unproductive loop or a continuous loop) is a loop which never ends. Inside loop, statements are repeated forever.

 while true do
   begin
   end;
 repeat
 until false;

Break statement

"While True Do" or "Repeat Until False" loops looks infinite at first glance, but there may be a way to escape the loop through Break.

var
  i:integer;
begin
  i := 0;
  while true do
    begin
      i := i + 1;
      if i = 100 then break;
    end;
end;
var
  i:integer;
begin
  i := 0;
  repeat
    i := i + 1;
    if i = 100 then break;
  until false;
end;

See also