ZX BASIC:WHILE

From BorielWiki

Jump to: navigation, search

Contents

[edit] WHILE

WHILE is a compound statement used to perform loops. The code within a WHILE statement will be repeated while the given condition be true. If the given condition is false the first time the inner sentences are never executed.

[edit] Syntax

WHILE expression
   sentences
END WHILE

or

WHILE expression
   sentences
WEND

The first form is preferred.

[edit] Examples

While a < b
   Let a = a + 1
   Poke a, 0
End While

An infinite loop:

While 1
  REM An infinite loop. This will issue a warning
  Print "Hello world!"
End While
Note: For infinite loops use DO..LOOP

[edit] Remarks

  • This statement does not exist in Sinclair Basic
  • WHILE can also be used with DO..LOOP (see DO for more information)

[edit] See Also

Personal tools