beautypg.com

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

Page 53

background image

RPBASIC-52 PROGRAMMING GUIDE

2-34

DO-WHILE

Syntax:

D O
{program stateme nts}
WH ILE {relation al expr}

Function:

Executes { program state ments} w hile {relational expr} is true .

Mode:

Run

Use:

100 CLEAR TICK(0) : DO : PRINT TICK(0) : WHILE TICK(0)<10

Cards:

All

D E S C R IP T I ON

The {prog ram statem ents} betw een DO and W HILE a re executed o nce, regardless of the {relational expr}
result. At WH ILE the {re lational expr} is evaluated. If true, all {program statements} are executed again,
and the test is repeated. If false, execution continues at the program statement after WHILE. DO-WHILE
and DO-UNT IL loops can be nested.

RELATED

D O - U N T IL , F O R -T O - S T E P- N E X T

EXAMPLE

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

10 ON LINE 0,0,500
20 DO
30 WHILE C=0
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