Ifs-Then-Else-End If Statements - Hitachi NT2021XA Instruction Manual

Easy-sequence programming software
Table of Contents

Advertisement

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
When
<condition>
is met, this instruction executes
executes
<instruction set
If neither "then
<instruction set
statement.
<condition>
:
Specifies a conditional expression among those listed in Section 2.2, " List of Instructions (2)
Conditional expressions."
<instruction set 1>
: Specifies the instructions to be executed when
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
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
executed in the second cycle. In the third cycle, the second instruction
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 program
Label
Mnemonic
ifs
then
Y(00)=
Y(01)=
else
Y(00)=
Y(01)=
end if
Structured if instruction
When
<condition>
described between "then" and "else."
When
<condition>
2>
described between "else" and "end if."
<instruction set 1>.
2>.
1>" nor "else
<instruction set
parameter1
parameter2
parameter3
X(00)
=
1
1
0
0
1
Description
is met, this instruction executes <instruction set 1>
is not met, this instruction executes
<condition>
When
<condition>
2>" is described, the ifs statement jumps to the end if
<condition>
is met. The instructions may be described
<condition>
is met. The instructions may be described
<instruction set 1>
<instruction set 1>
parameter4
parameter5
2-9
Chapter 2 Syntax
<instruction set
is met.
is not met, this instruction
or
<instruction set 2>
or
<instruction set 2>
is executed
When <condition>
When <condition>
is met
is not met
(1)
(1)
(2)
(3)
(2)
(3)
(4)
(4)
is

Advertisement

Table of Contents
loading

Table of Contents