WHILE...LOOP
 
Syntax

[DO] WHILEcondition
    [statements]
LOOP
Description


WHILE [...] LOOP will repeat the statements between WHILE and LOOP, while the condition is true.

If the condition isn't true when the WHILE statement begins, none of the statements will be run.

The DO is optional in ARMbasic.

WHILE loops have the lowest overhead of all looping constructs, so they are faster than FOR or DO loops

An EXIT is the proper way to leave a WHILE...LOOP, you can also use a GOTO or RETURN statement.

Example


' a good way to time operations
        
x = 1000000

while x
        x -=
1   ' decrement x
        y = y * z    ' do something to measure here -- like multiply for instance
loop

-----------------------------------
      
   ... Finished in 181 msec  (on PROplus)

       
so with loop overhead of 121 msec, that's 60 nsec to multiply 2 numbers

Differences from other BASICs


See also