beautypg.com

Basic programming guide, Do-while – Remote Processing BASIC for the CX-10 Modbus User Manual

Page 25

background image

BASIC PROGRAMMING GUIDE

2-16

DO-WHILE

Syntax:

DO
{program statements}
WHILE {relational expr}

Function:

Executes {program statements} while {relational expr} is true.

Mode:

Run

Use:

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

DESCRIPTION

The {program statements} between DO and WHILE are executed once, regardless of the {relational expr}
result. At WHILE the {relational 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-UNTIL loops can be nested.

RELATED

DO-UNTIL, FOR-TO-STEP-NEXT

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