Ifs-Then-Else-End If Statements - Hitachi SJ700-2 Series Instruction Manual

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

Advertisement

Chapter 5 Instruction Words

ifs-then-else-end if statements

- Format
Format
ifs <condition>
[then]
<instruction set 1>
[else]
<instruction set 2>
end if
- Explanation
This instruction executes different sets of instructions according to whether <condition> is met.
When <condition> is met, this instruction executes <instruction set 1>. When <condition> is not met,
this instruction executes <instruction set 2>.
If neither <instruction set 1> nor <instruction set 2> is described, the ifs statement jumps to the end if
statement.
<condition>:
Specifies a conditional expression among those listed in Section 3.5, "Conditions," of
Chapter 3, "Syntax."
<instruction set 1>: Specifies the instructions to be executed when <condition> is met. The instructions
may be described on two or more lines. The instructions are executed in units of lines
in a cycle as explained below.
<instruction set 2>: Specifies the instructions to be executed when <condition> is met. The instructions
may be described on two or more lines. The instructions are executed in units of lines
in a cycle as explained below.
- Processing cycle
Note that <condition> is checked in the first cycle, and the first instruction in <instruction set 1> or
<instruction set 2> is executed in the second cycle. In the third cycle, the second instruction <instruction
set 1> or <instruction set 2> is executed or, if no other instruction remains in the instruction set,
processing jumps to the end if statement. Therefore, the routine from "ifs" to "end if" is executed in three
cycles when the instruction set contains only one instruction.
Refer to the statement execution sequence indicated by parenthesized numbers in the comment fields
of the sample programs below.
- Sample programs
ifs
X(00) =
then
Y(00) =
Y(01) =
else
Y(00) =
Y(01) =
end if
Structured if instruction
When <condition> is met, this instruction executes <instruction set 1>
described between "then" and "else."
When <condition> is not met, this instruction executes <instruction
set 2> described between "else" and "end if."
1
1
0
0
1
Description
When <condition> is met
(1)
(2)
(3)
(4)
5 - 6
When <condition> is not met
(1)
(2)
(3)
(4)

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sj700 series

Table of Contents