while statement

The while statement can be used to repeatedly execute a sequence of statements as long as a condition is satisfied.
      while expression
          statement group
      end
What it does is evaluate expression first. If its logic value is true, the statement group is executed. Then expression is evaluated again, and if it is true statement group is executed again. This is repeated over and over until the value of expression becomes false. For example:
 
      s=0;
      k=1;
      while  k <= 100
         s += k++;
      end
The execution of the loop commands should be able to affect the value of the expression, so that the loop comes to an end at some point. Otherwise, it will run forever, and the interpreter will have to be closed by the operating system.



oz 2009-12-22