While Loop Statement - Hitachi SJ700-2 Series Instruction Manual

Easy-sequence programming software ezsq
Hide thumbs Also See for SJ700-2 Series:
Table of Contents

Advertisement

- Processing cycle
Refer to the statement execution sequence indicated by parenthesized numbers in the comment fields
of the sample programs below.
(1):
The "for" line is executed only once.
(2) and (3): <instruction set> is executed.
(4):
<variable> is incremented in the cycle that follows the cycle in which the last instruction of
<instruction set> is executed. Then, <variable> is checked to determine whether to exit the
loop (in other words, the next statement is executed). When repeating the loop, processing
returns to the first instruction of <instruction set> in this cycle.
(5):
This step is executed in the next cycle.
(6) to (10): These steps are repeated in the same way as the preceding loop execution.
(11):
Processing proceeds to the following step (line).
- Sample program
for
U(00)
Y(00) =
1
Y(00) =
0
next
Y(00) =
1

while loop statement

- Format
Format
while <condition>
<instruction set>
wend
- Explanation
This instruction executes <instruction set> repeatedly as long as <condition> is met. Note that
<condition> is checked before the execution of <instruction set>. If <condition> is not met, processing
proceeds to the wend statement without executing <instruction set>.
- Sample program (Condition "X (00) = 0" is met after the loop is executed twice.)
while
X(00) =
Y(00) =
1
Y(00) =
0
wend
Y(00) =
1
0
3
1
Instruction to conditionally execute a pre-conditioned loop
This instruction executes <instruction set> while <condition> is met.
Note that <condition> is checked before the execution of <instruction
set>.
Is <condition> met?
Execute <instruction set>
1
Chapter 5 Instruction Words
Sequence of execution
:(1) 
   
:(2)  (5)  (8) 
:(3)  (6)  (9) 
:(4)  (7)  (10) 
: 
 
(11) 
Description
No
Yes
Sequence of execution
:(1)  (5)  (9) 
:(2)  (6) 
:(3)  (7) 
:(4)  (8) 
:        (10)
5 - 9

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sj700 series

Table of Contents