Do...Loop Statement

Repeats a block of statements while a condition is True or until a condition becomes True.

Do

   [statements]    [ExitLoop]

   [statements]

Loop {While | Until} condition

 

Remarks

The ExitLoop can only be used within a Do...Loop control structure to provide an alternate way to exit a Do...Loop. Any number of ExitLoop statements may be placed anywhere in the Do...Loop. Often used with the evaluation of some condition (for example, If...Then), ExitLoop transfers control to the statement immediately following the Loop

When used within nested Do...Loop statements, ExitLoop transfers control to the loop that is nested one level above the loop where it occurs.

 

Example

Dim lop as integer

lop = 1

DO

   answer = "1"   

   LOAD

   answer = "0"

   LOAD

   lop= lop + 1

   if lop = 3 then

     exitloop

   endif

   answer = "1"

   LOAD

LOOP UNTIL lop = 8