BOOL_TO_<type>
This IEC operator converts from the data type BOOL to a different data type.
Syntax: BOOL_TO_<data type>
With numerical data types the result is 1 if the operand is TRUE and 0 if the operand is FALSE. With the data type STRING the result is TRUE or FALSE.
Samples:
ST code | Result |
---|---|
nVar := BOOL_TO_INT(TRUE); | 1 |
sVar := BOOL_TO_STRING(TRUE); | 'TRUE' |
tVar := BOOL_TO_TIME(TRUE); | T#1ms |
tVar := BOOL_TO_TOD(TRUE); | TOD#00:00:00.001 |
dVar := BOOL_TO_DATE(FALSE); | D#1970 |
dtVar := BOOL_TO_DT(TRUE); | DT#1970-01-01-00:00:01 |
FBD code | Result |
---|---|
1 | |
'TRUE' | |
T#1ms | |
TOD#00:00:00.001 | |
D#1970-01-01 | |
DT#1970-01-01-00:00:01 |
See also:
- Data types > BOOL