Chapter 2 Syntax
2-9
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 “then
<instruction set 1>
“ nor “else
<instruction set 2>
“ is described, the ifs statement jumps to the end if
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
<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
program
When <condition>
is met
When <condition>
is not met
Label
Mnemonic
parameter1
parameter2
parameter3
parameter4
parameter5
㩷
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)
Summary of Contents for NT2021XA
Page 4: ... Safety Instructions ...
Page 8: ... Contents ...
Page 10: ...Chapter 1 Outline of EzSQ ...
Page 14: ...1 4 Chapter 1 Outline of EzSQ ...
Page 16: ...Chapter 2 Syntax ...
Page 68: ...2 52 Chapter 2 Syntax ...
Page 70: ...Chapter 3 Interface with the Inverter ...
Page 80: ...3 10 Chapter 3 Interface with the Inverter ...