SEL - Return One of Two Values

Help Contents


The select function, SEL, returns one of two values depending on the value of a boolean (BOOL) selector value.

Informal Syntax:

SEL( G, IN0, IN1 )

Formal Syntax:

SEL( G:=expression, IN0:=expression, IN1:=expression )


GBOOLThe selector value.
IN0ANYThe value returned if G is FALSE.
IN1ANYThe value returned if G is TRUE.

Return value

If G is FALSE, SEL returns IN0.

If G is TRUE, SEL returns IN1.

The type of the return value is the "highest" type of the two inputs IN0 and IN1. For example if IN0 is type SINT and IN1 is type INT, the return type of the SEL function would be INT.

See Automatic Type Promotion for further information.


ExampleReturn Value
SEL( FALSE, 'Off', 'On')STRING#'Off'
SEL( G:=1, In0:=T#0s, In1:=T#10s)TIME#10s

Standards Compliance

Table 27.1 - IEC 61131-3 Second Edition.

Table 32.2 - IEC 61131-3 Third Edition.

Further Information

Selection Functions

To learn about other selection functions.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.