A do loop is one way to repeat a section of code more than once.
After each time the loop is executed, the condition is checked.
If the condition is true, then the loop body starts over from the top.
loop while <CONDITION>
<BODY> is the code to execute repeatedly.
<CONDITION> is a Boolean expression indicating whether the loop should repeat for another iteration.
Consider the following example.
dim num as Number
print "Enter a number: ";
loop while num <> 0
The execution looks like the following flow chart.
┌─>│ print "Enter a number: "; │
│ │ input num │
└───────────│ num? │
num <> 0 └──────┘
↓ num = 0
This is similar to a while loop.
In a do loop, the condition is checked after running the loop body.
In a while loop, the condition is checked before running the loop body.
This means that a do loop will always execute at least once, but a while loop can execute zero times.