2-299
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Selection Instructions
2
SEL
The SEL instruction selects one of two selections, In0 and In1. Gate G specifies which of In0 and In1 to
select. If G is FALSE, In0 is assigned to Out. If G is TRUE, In1 is assigned to Out.
The following example is for when In0 is INT#10, In1 is INT#20, and G is TRUE. The value of variable
abc will be INT#20.
Use the MUX instruction (page 2-300) to select one of two or more selections.
• In0, In1, and Out may be different data types, but observe the following precautions.
• Set the valid range of Out to include the valid ranges of In0 and In1.
• In0, In1, and Out cannot be different varieties of data types (such as a bit string and an integer, or
an integer and a text string).
• An error occurs in the following cases. ENO will be FALSE, and Out will not change.
• In0 or In1 is STRING data and the number of bytes in the selection result exceeds the size of the
output parameter that is connected to Out.
• In0 or In1 is STRING data and it does not end in a NULL character.
Function
Additional Information
Precautions for Correct Use
FALSE
TRUE
G
Out: = In1 Out: = In0
abc:=SEL(TRUE, INT#10, INT#20);
LD ST
INT#20
TRUE
INT#10
abc
SEL
EN ENO
G
In0
In1