WHILE ... END WHILE
WHILE … END WHILE
Section titled “WHILE … END WHILE”WHILE is a compound statement used to perform loops. The code within a WHILE statement will repeat while the given condition is true. If the given condition is false the first time the inner sentences are never executed.
Syntax
Section titled “Syntax” WHILE expression sentences END WHILEor
WHILE expression sentences WENDThe first form is preferred.
Examples
Section titled “Examples”While a < b Let a = a + 1 Poke a, 0End WhileAn infinite loop:
While 1 REM An infinite loop. This will issue a warning Print "Hello world!"End WhileNote: For infinite loops use DO … LOOP
Remarks
Section titled “Remarks”- This statement does not exist in Sinclair Basic.
- WHILE can also be used with DO … LOOP.