SEL block
Short summary
Name |
SEL |
→POU type |
|
Category |
|
Conform to →IEC-standard |
currently restricted |
Graphical interface |
|
Available since |
|
Functionality
The block makes a binary selection.
If input G is set to value FALSE (or an equivalent), the block returns the value of input IN0. If input G is set to value TRUE (or an equivalent), the block returns the value of input IN1.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
G |
BOOL |
selector |
IN1 |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference |
1st value |
|
IN2 |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference |
2nd value |
|
Return value: |
– |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE, TIME_OF_DAY, a →user-defined data type or a →reference |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Example for usage within ST-editor
PROGRAM Test
VAR
result1 : INT;
result2 : DINT;
END_VAR
result1 := SEL(G := FALSE, IN0 := INT#
1
, IN1 := USINT#
2
); (* The variable
'result'
evaluates to
'1'
. *)
result2 := SEL(G := TRUE, IN0 := DINT#
1
, IN1 := USINT#
2
); (* The variable
'result'
evaluates to
'2'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.