SEL - Return One of Two Values

Help Contents

Introduction

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

Syntax

Informal Syntax:

SEL( G, IN0, IN1 )

Formal Syntax:

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

Parameters

ParameterTypeDescription
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.

Examples

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

Standards Compliance

IEC 61131-3 Second Edition: Table 27.1.

IEC 61131-3 Third Edition: Table 32.2.

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.

Glossary

For the meaning of terms used in Fernhill SCADA.