Skip to main content

DO...LOOP

Syntax

[DO] WHILE condition     [statement block] LOOP DO     [statement block] [LOOP] UNTIL  condition

DO     [statement block] LOOP

Description

Repeats a block of statements until/while the condition is met.  The three above syntaxes show the different types.   The DO .. LOOP without a WHILE or UNTIL will loop forever, unless an EXIT statement is executed.

Example

'This will continue to print "hello" on the screen until the condition (a > 10) is met.

a = 1

DO

PRINT "hello"

a += 1

LOOP UNTIL a > 10

Differences from other BASICs

  • Some BASICs allow interchangeablilty of UNTIL as the equivalent of NOT WHILE

See also