EasyManua.ls Logo

Hitachi SJ700-2 Series - Ifs-Then-Else-End if Statements

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 - 6
ifs-then-else-end if statements Structured if instruction
- Format
Format Description
ifs <condition>
[then]
<instruction set 1>
[else]
<instruction set 2>
end if
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."
- 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
When <condition> is met When <condition> is not met
ifs X(00) = 1 (1) (1)
then
Y(00) = 1 (2)
Y(01) = 0 (3)
else
Y(00) = 0 (2)
Y(01) = 1 (3)
end if (4) (4)

Table of Contents

Related product manuals