beautypg.com

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

Page 24

background image

BASIC PROGRAMMING GUIDE

2-15

DO-UNTIL

Syntax:

DO
{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 : UNTIL A=4 : PRINT "Done"

DESCRIPTION

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 CLEAR or CLEAR S statement.

This statement always executes to UNTIL once. When relational expr is evaluated and if it is false, program
flow branches back to DO. If true, program resumes at the next statement after UNTIL.

When there are no {program statements} between DO and UNTIL, and {relational expr} is false, the "loop"
will repeat forever, or until a is typed at the console.

DO-UNTIL and DO-WHILE loops can be nested.

RELATED

DO-WHILE, FOR-TO-NEXT-STEP

ERROR

BAD SYNTAX

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