EasyManua.ls Logo

Hitachi SJ700-2 Series - While Loop Statement

Hitachi SJ700-2 Series
134 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 5 Instruction Words
5 - 9
- 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
Sequence of execution
for U(00) 0 3 1 (1) 
Y(00) = 1 (2) (5) (8)
Y(00) = 0 (3) (6) (9)
next (4) (7) (10)
Y(00) = 1 : (11)
while loop statement Instruction to conditionally execute a pre-conditioned loop
- Format
Format Description
while <condition>
<instruction set>
wend
This instruction executes <instruction set> while <condition> is met.
Note that <condition> is checked before the execution of <instruction
set>.
- 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>.
Execute <instruction set>
Is <condition> met?
Yes
No
- Sample program (Condition "X (00) = 0" is met after the loop is executed twice.)
Sequence of execution
while X(00) = 1 (1) (5) (9)
Y(00) = 1 (2) (6)
Y(00) = 0 (3) (7)
wend (4) (8)
Y(00) = 1 (10)

Table of Contents

Related product manuals