Statements: do – while [rel expr – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual
Page 58
Advertising
![background image](/manuals/579830/58/background.png)
Operating Functions
Chapter 5
5–21
Mode: RUN
Type: CONTROL
The
DO – WHILE [rel expr] instruction provides a means of “loop
control” within a module program. The operation of this statement is
similar to the DO –
UNTIL [rel expr] except that all statements
between
the DO and the WHILE [rel expr] are executed as long as the
relational
expression following the WHILE statement is true. You can
nest
DO – WHILE and DO – UNTIL statements.
Examples:
SIMPLE DO-WHILE
NESTED
DO-WHILE - DO-UNTIL
u10 DO
u10 DO
u20 A=A+1
u20 PRINT A=A+1
u30 PRINT A
u25 DO
u40 WHILE At4
u30 B=B+1
u50 PRINT “DONE”
u40 A,B,A*B
u60 END
u50 WHILE Btu3
uRUN
u60 B=0
u70 UNTIL A=3
u80 END
uRUN
1
1 1 1
2
1 2 2
3
1 3 3
4
2 1 2
DONE
2 2 4
2 3 6
READY
3 1 3
u
3 2 6
3 3 9
READY
u
5.4.9
Statements: DO – WHILE
[rel expr] (continued)
Advertising