DO (BASIC 3.5)
in BASIC ROM:
|List of all BASIC keywords|
Type: Command General Programming-Syntax: DO [UNTIL boolean argument WHILE boolean argument] statements [EXIT] LOOP [UNTIL boolean argument WHILE boolean argument]
DO is a BASIC 3.5 command that is used for performing a loop.
Performs the statements between the DO statement and the LOOP statement. If no UNTIL or WHILE modifies either the DO or the LOOP statement, execution of the intervening statements continues indefinitely.
If an EXIT statement is encountered in the body of the DO loop, execution is transferred to the first statement following the LOOP statement.
DO loops may be nested, following the rules defined for FOR-NEXT loops.
If the UNTIL parameter is used, the program continues looping until the boolean argument is satisfied (becomes TRUE).
The WHILE parameter is basically the opposite of the UNTIL parameter: the program continues looping as long as the boolean argument is TRUE.
Examples[edit | edit source]
DO WHILE A$="":GET A$:LOOP
In this example, the loop is executed until the joystick is moved into port 1 or its fire button is pressed.