Chapter 7
151
UM10372_PCNC440_Manual_0221A
PROgRAMMiNg
7.8.1.5 Looping Subroutines
Subrounes can be looped using the Do/while or while/endwhile keyword constructs.
Do/While Loop
The Do/While loop executes a block of code once and connues to execute the code block unl the
while argument evaluates to true.
Do/While Loop Example:
#1 = 0 (assign parameter #1 the value of 0)
o100 do
(debug, parameter 1 = #1)
o110 if [#1 EQ 2]
#1 = 3 (assign the value of 3 to parameter #1)
(msg, #1 has been assigned the value of 3)
o100 continue (skip to start of loop)
o110 endif
(some code here)
#1 = [#1 + 1] (increment the test counter)
o100 while [#1 LT 3]
M02
While/endwhile
The while/endwhile repeats a set of statements an indenite number of mes, as long as the while
argument evaluates to true.