Node:while, Next:, Previous:Void, Up:Reference



while

Synopsis


while boolean_expression do
  statement

Description

The while statement declares a loop. For further description see while Statement.

Conforming to

while is defined in ISO 7185 Pascal and supported by all known Pascal variants.

Example


program WhileDemo;
var
  Foo, Bar: Integer;
begin
  WriteLn ('Enter an descending series of integer numbers.');
  WriteLn ('Terminate by breaking this rule.');
  WriteLn ('Enter start number: ');
  Bar := MaxInt;
  ReadLn (Foo);
  while Foo < Bar do
    begin
      Bar := Foo;
      ReadLn (Foo)
    end;
  WriteLn ('The last number of your series was: ', Bar)
end.

See also

Keywords, repeat Statement, for Statement.