Do…Loop will infinitely loop the enclosed commands unless Do While or Do Until is used to conditionally terminate the loop. An Exit Do statement can also be used within the DO…LOOP to exit from the loop.
Do Commands Loop
Dim K As Integer Do K=Adin(0) ' Read AD input from channel 0 Debug Dec K,Cr Delay 1000 Loop
In the above example, the program will loop indefinitely inside Do and Loop. An Exit Do or GOTO statement must be used to get out of the infinite loop.
Do While [Condition] Commands [Exit Do] Loop Do Commands [Exit Do] Loop While [Condition]
Do…While will loop indefinitely until the While condition is met.
Do Until [Condition] Commands [Exit Do] Loop Do Commands [Exit Do] Loop Until [Condition]
Do…Until will loop indefinitely until Until condition is met.