modula-2 home

  Win32 API  


While statements

While statements specify the repeated execution of a statement sequence depending on the value of a Boolean expression. The expression is evaluated before each subsequent execution of the statement sequence. The repetition stops as soon as this evaluation yields the value FALSE.

   WhileStatement = WHILE expression DO StatementSequence END.


   WHILE j > 0 DO
      j:= j DIV 2;
      i:= i+1

   WHILE i#j DO
      IF 1 > j THEN i : = i-j
      ELSE j:= j-i

   WHILE (t # NIL) & (t^.key # i) DO
      t : = t^.left


  • Wirth N: Programming in Modula-2, 3rd ed. Springer Verlag, Berlin, 1985.
  • Stony Brook Modula-2 documentation. Used with permission. Note: Stony-Brook M2 offers an extended syntax with features not described here. Stony Brook M2 users are encouraged to visit the Stony Brook website and to consult the Stony Brook help system.