Вопрос

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
Это было полезно?

Решение

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()

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top