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
../_images/f064862cbc343122c0a8640e01110c7b 1
../_images/5fbd318cbc3657f9c0a8640e0052117a TRUE
../_images/e60ad9ddbc3771a1c0a8640e0159ad54 T#1ms
../_images/50f16815bc38dbf5c0a8640e00848c8e TOD#00:00:00.001
../_images/c7c883c6bc249026c0a8640e0199efec D#1970-01-01
../_images/277b5c65bc2cc6e5c0a8640e00ce4b9c DT#1970-01-01-00:00:01