Operator ‘BOOL_TO’¶
This IEC operator is used for converting the BOOL
data type to another data type.
BOOL_TO_<data type>
For numeric types, the result is 1
if the operand is TRUE
, and 0
if the operand is FALSE
.
For the STRING
data type, the result is TRUE
or FALSE
.
Examples
ST Code | Result |
---|---|
i := BOOL_TO_INT(TRUE); |
1 |
str := BOOL_TO_STRING(TRUE); |
TRUE |
t := BOOL_TO_TIME(TRUE); |
T#1ms |
tof := BOOL_TO_TOD(TRUE); |
TOD#00:00:00.001 |
dat := BOOL_TO_DATE(FALSE); |
D#1970 |
dandt := 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 |