Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

DO ... LOOP ... UNTIL

Description

The DO...LOOP statement can be used in two ways. You have the option to form uncontrolled (endless) loops if the LOOP statement has no following UNTIL. In this cane, the enclosing block is executed over and over. To get out of an endless loop use the GOTO statement. If there's an UNTIL imediately after the LOOP statement, you have a condition-controlled loop that runs at least once, because the condition is checked at the end. 

Example

The following program is an endless loop. It prints out the string "hello" multiple times, until the program is stopped by an external event or the module is powered off.

outmode -2
do
   print "hello"
loop

In the next example there's a condition at the end, that causes the loop to run only ten times.  

outmode -2
let a = 0
do
   print "hello"
   let a = a + 1
loop until a = 10

Remarks

In some cases, head-controlled loops are more suitable than DO...WHILE loops. Please see also the WHILE and FOR pages.