Pregunta

I wonder if it is allowed by the standard (IEC 1131-3) to mix different data types in an expression.

Example

VAR A : BOOL;
    B : INT;

(* ... *)

IF (B AND C) THEN
  ...
END_IF
¿Fue útil?

Solución

You must use the explicit type conversion functions when converting "down" in types. "up" conversion is done implicitly.

VAR A : BOOL;
    B : INT;
(* ... *)
IF (INT_TO_BOOL(B) AND C) THEN
  ...
END_IF

There are all forms of these type conversion in the form of TYPEA_TO_TYPEB()

Otros consejos

It will not compile. Type conversion is needed since ST is type strict as Pascal.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top