Please enable JavaScript to view this site.


Navigation: Macros > Macro Language > Instructions > Looping

Looping with the  WHILE  Keyword

Scroll Prev Up Next More

The while looping instruction is used to repeat a block of instructions until a certain condition is true.


Before the block to be repeated, place a while statement containing the boolean expression that determines if the loop will be performed.

while SomeBooleanExpressionIsTrue
   // do something

The whole point of the while loop is to re-evaluate a condition prior to every loop (which means that if the condition is false from the beginning, the loop will never be entered). Recall that the elements of a for loop could not be modified in the loop, nor could they vary, but in the case of a while loop the following is allowed and often used.

// increase the date until we reach a Saturday
while WeekDayOf(nDate) <> 6

To interrupt the flow of a while loop, use the break or continue commands.


See also: for loops.


Topic 105132, last updated on 18-Apr-2020