The following Help section for Data Type > Structure implies that it is possible to compare structures:
"If the target system supports the data type, as from compiler version >= 3.5.7.0 you can compare operands of type STRUCT (structure). Example: IF (stStruct1 := stStruct2) THEN...." .
(I assume this is a typo and should read IF (struct1 = struct2) THEN ...)
Using Control Win V3 Version 3.5.7.10, I have:
TYPE TestDUT :
STRUCT
MyInt: INT;
END_STRUCT
END_TYPE
VAR
struct1: TestDUT;
struct2: TestDUT;
testBool: BOOL;
END_VAR
IF (struct1 = struct2) THEN
testBool := TRUE;
END_IF
This generates the error:
Cannot compare type 'TestDUT' with type 'TestDUT'
Have I made an error or is this feature not supported on the target system?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following Help section for Data Type > Structure implies that it is possible to compare structures:
"If the target system supports the data type, as from compiler version >= 3.5.7.0 you can compare operands of type STRUCT (structure). Example: IF (stStruct1 := stStruct2) THEN...." .
(I assume this is a typo and should read IF (struct1 = struct2) THEN ...)
Using Control Win V3 Version 3.5.7.10, I have:
TYPE TestDUT :
STRUCT
MyInt: INT;
END_STRUCT
END_TYPE
VAR
struct1: TestDUT;
struct2: TestDUT;
testBool: BOOL;
END_VAR
IF (struct1 = struct2) THEN
testBool := TRUE;
END_IF
This generates the error:
Cannot compare type 'TestDUT' with type 'TestDUT'
Have I made an error or is this feature not supported on the target system?
Hi
not sure that you could still compare structure directly. But you could do it with pointers, using the Sysmemcmp function in library Sysmem.
IF sysmemcmp(pstruct1,pstruct2, SIZEOF(struct1)) <> 0 THEN
testBool := TRUE;
ELSE
testBool := FALSE;
END_IF
something as above
Great, that's exactly what I need, thanks.