IEC selection operator for binary selection.
G determines whether IN0 or IN1 is assigned to OUT.
OUT := SEL(G, IN0, IN1) means:
OUT := IN0; if G=FALSE
OUT := IN1; if G=TRUE
Allowed data types:
IN0, ...,INn and OUT can be any identical data type. Make sure that variables of the identical data type are used at these positions, especially when using user-defined data types. The compiler verifies the identity of the types and returns compiler errors. Assigning function block instances to interface variables is not supported.
G: BOOL
LD TRUE
SEL 3,4 (* IN0 = 3, IN1 =4 *)
ST Var1 (* result is 4 *)
LD FALSE
SEL 3,4
ST Var1 (* result is 3 *)
Var1:=SEL(TRUE,3,4); (* result is 4 *)
NOTE: An expression occurring ahead of IN0 will not be processed if G is TRUE. An expression occurring ahead of IN1 will not be processed if G is FALSE.