4.5) while...do...endwhile Statement
If you need a loop for which you don't know in advance how many iterations there will be, you can use the WHILE statement. This takes the form:
WHILE condition DO statement
Or
WHILE condition DO BEGIN statement 1 statement 2 statement2 ENDWHILE
Here, the "condition" is constructed in the same way as the IF statement, and whilst the conditions is true, the statements within the loop will continue to be executed. So for example:
I = 0 WHILE I lt 10 DO BEGIN print, I I++ ENDWHILE
This will print the numbers 0 to 9 to the screen.