beautypg.com

Rpbasic-52 programming guide, Do-until – Remote Processing BASIC 52 User Manual

Page 52

background image

RPBASIC-52 PROGRAMMING GUIDE

2-33

DO-UNTIL

Syntax:

D O
{program statements}
UNTIL relational expr
Where: relational expr is any logical evaluation such as =, <, >, etc.

Function:

Executes a number of program statements a relational expression is true.

Mode:

Run

Use:

100 A=0 : DO : A=A+1 : PRINT A : UNT IL A=4 : PRINT "Done"

Cards:

All

D E S C R IP T I ON

This statement always executes at least once. DO-UNTIL loops may be nested. This loop may be exited
without meeting relational expr by executing a CLE AR or C LEA R S statem ent.

This statement always executes to UNTIL once. When relational expr is evaluated and if it is false, program
flow b ranch es bac k to D O. If true , progra m res ume s at the next sta teme nt after UN TIL.

When there are no {pro gram statem ents} betw een DO and UN TIL, and {re lational expr} is false, the "loop"
will repeat forever, or until a is typed at the console.

DO-UNT IL and DO-WH ILE loops can be nested.

RELATED

DO-WHILE, FOR-TO-NEXT-STEP

E R R O R

B A D S Y N T A X

When relational expr is omitted

EXAMPLE

The following program stays in a DO-UNTIL loop until a line has changed.

10 ON LINE 0,0,500
20 DO
30 UNTIL C=1
40 PRINT "Line 0 changed. Is now a",line(0)
50 C=0
60 GOTO 20
500 C=1
510 RETURN

>run
Line 0 changed. Is now a 0
Line 0 changed. Is now a 1
Line 0 changed. Is now a 0