The function compares two structured actual parameters (array, PLC data type) and outputs whether they are of the same type and have the same values.
Compare arrays or plc datatypes and their values up to a max lengh of 200 Bytes of the connected variables. If at least one value of an element is not identical --> set function result = false
Restrictions:
The attached structure must not include Strings
The attached structure can not exceed 200 bytes, because of the internal buffer size
LGF_CompareVariant (FC) | ||||||||
---|---|---|---|---|---|---|---|---|
Ret_Val | Bool | |||||||
error | Bool | |||||||
status | Word | |||||||
subFunctionStatus | Word | |||||||
Variant | variableA | Variant | ||||||
Variant | variableB | Variant | ||||||
Identifier | Data type | Description |
---|---|---|
Ret_Val | Bool | FALSE: Values of comparison variables or PLC data types are different. TRUE: Values of the comparison variables are equal and PLC data types are identical. |
error | Bool | FALSE: No error / TRUE: An error occurred during the execution of the FB |
status | Word | 16#0000-16#7FFF: Status of the FB / 16#8000-16#FFFF: Error identification (see following Table) |
subFunctionStatus | Word | Status or return value of called FB's, FC's and system blocks |
Identifier | Data type | Description |
---|---|---|
variableA | Variant | First comparison variable with any data type |
variableB | Variant | Second comparison variable with any data type |
Code / Value | Identifier / Description |
---|---|
16#0000 | STATUS_NO_ERROR Execution finished without errors |
16#8201 | ERR_INPUT_TYPES_MUST_MATCH Error, the input types must match, e.g. STRUCT |
16#8202 | ERR_INPUT_TYPES_LENGTH_NOT_EQUAL Error, the input types have different lengths after serialization, `subFunctionStatus` provides an indicator of the different size |
16#8601 | ERR_SERIALIZE_VARIABLE_A Error occured while serialize variableA into Bytearray - see `subFunctionStatus` for detailed information |
16#8602 | ERR_SERIALIZE_VARIABLE_B Error occured while serialize variableB into Bytearray - see `subFunctionStatus` for detailed information |
subFunctionStatus
. In this case, the output value in status
indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.This block compares two (structured) actual parameters and shows whether they equate to the same value.
The following differences cannot be detected with the comparison method (byte level):
Struct
cannot be compared.REAL
numbers in the structure, a disparity can also be displayed for "same" variables.ARRAY of BOOL
cannot be checked for equality with the function, because the command used, CountOfElements
, also counts the filling elements (e.g. 8 is returned with an ARRAY[0..1] of BOOL
).Version & Date | Change description | |
---|---|---|
01.00.00 | Siemens Industry Online Support | |
03.09.2015 | First released version | |
01.00.01 | Siemens Industry Online Support | |
11.02.2015 | Bug fix | |
01.00.02 | Siemens Industry Online Support | |
02.01.2017 | Upgrade: TIA V14 Update 1 | |
01.00.03 | Siemens Industry Online Support | |
17.08.2018 | Upgrade: TIA V15 Update 2 | |
01.00.04 | Siemens Industry Online Support | |
23.11.2018 | Upgrade: TIA V15.1 | |
01.00.05 | Simatic Systems Support | |
03.06.2019 | Refactoring and performance improvment Change error handling to status and subFctStatus update serialize instruction add eno handling | |
03.00.00 | Simatic Systems Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
19.01.2020 | Insert documentation |