[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 WHILE                       Loop Until Condition                     pp 61


 Define:  Loop until Boolean condition matches control statement.

 Purpose: Allow looping for an indeterminate amount of repetitions.

 Notes:   The expression controlling the repetition must be of type Boolean.
          The statement is repeatedly executed as long as Expression
          is True.  If Expression is False at loop entry, the loop is not
          executed at all.

          Testing is done at the top of the loop.


 ----------------------------------------------------------------------------


 Usage:
       VAR
          Final       : Integer            ; { Ending value of loop Control }
          Control     : Integer            ; { Declare a control variable   }

       BEGIN
          Final       := 10                ; { Finish with 10               }
          Control     :=  1                ; { Start at 1                   }
          While Control < Final Do           { Boolean test of Control      }
            Begin
            Control   := Control + 1       ; { Control is loop indexer      }
            WriteLn (Control)              ; { Control = Final at exit      }
            End                            ; { End of compound statements   }

          Control     :=  1                ; { Start at 1 again             }

          While Control <= Final Do
            Begin
            Control   := Control + 1       ;
            WriteLn (Control)              ; { Control = Final + 1 at exit  }
            End                            ;
       END.

See Also: For/To Repeat
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson