Rockwell-automation 1746-BAS BASIC LANGUAGE User Manual Page 87

  • Download
  • Add to my manuals
  • Print
  • Page
    / 280
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 86
Publication 1746-RM001A-US-P
Control Functions 7-3
DO-WHILE
Purpose
Use the DO-WHILE statement to set up loop control within a module program.
The operation of this statement is similar to the DO-UNTIL [rel expr]. 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 statements.
The control stack (C-stack) stores all information associated with loop control
(example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines). The
control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops and GOSUB
commands use 3 bytes of the control stack. FOR-NEXT loops use 17 bytes.
Syntax
DO-WHILE [rel expr]
Examples
Simple DO-WHILE
>NEW
>1 REM EXAMPLE PROGRAM
>10 DO
>20A=A+1
>30 PRINT A
>40 WHILEA<4
>50 PRINT “DONE”
>60 END
READY
>RUN
1
2
3
4
DONE
READY
>
Nested DO-WHILE
>NEW
IMPORTANT
Excessive nesting exceeds the limits of the control stack,
generating an error, and causing the module to enter Command
mode.
Page view 86
1 2 ... 82 83 84 85 86 87 88 89 90 91 92 ... 279 280

Comments to this Manuals

No comments