LGF_CompareVariant (FC / V3.0.1)


Author: Siemens Digital Industry

Short description

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

Block Interface

LGF_CompareVariant (FC)
   Ret_Val  Bool
    
   error  Bool
    
   status  Word
    
   subFunctionStatus  Word
    
Variant  variableA  Variant
       
Variant  variableB  Variant
       
   

Output parameter

IdentifierData typeDescription
Ret_ValBoolFALSE: Values of comparison variables or PLC data types are different.
TRUE: Values of the comparison variables are equal and PLC data types are identical.
errorBoolFALSE: No error / TRUE: An error occurred during the execution of the FB
statusWord16#0000-16#7FFF: Status of the FB / 16#8000-16#FFFF: Error identification (see following Table)
subFunctionStatusWordStatus or return value of called FB's, FC's and system blocks

In/Out parameter

IdentifierData typeDescription
variableAVariantFirst comparison variable with any data type
variableBVariantSecond comparison variable with any data type

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Execution finished without errors
16#8201ERR_INPUT_TYPES_MUST_MATCH
Error, the input types must match, e.g. STRUCT
16#8202ERR_INPUT_TYPES_LENGTH_NOT_EQUAL
Error, the input types have different lengths after serialization, `subFunctionStatus` provides an indicator of the different size
16#8601ERR_SERIALIZE_VARIABLE_A
Error occured while serialize variableA into Bytearray - see `subFunctionStatus` for detailed information
16#8602ERR_SERIALIZE_VARIABLE_B
Error occured while serialize variableB into Bytearray - see `subFunctionStatus` for detailed information

Functional description

NOTE
The status of called commands is output in 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.

Note

The following differences cannot be detected with the comparison method (byte level):

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
03.09.2015First released version
01.00.01Siemens Industry Online Support
11.02.2015Bug fix
01.00.02Siemens Industry Online Support
02.01.2017Upgrade: TIA V14 Update 1
01.00.03Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.04Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.00.05Simatic Systems Support
03.06.2019Refactoring and performance improvment
Change error handling to status and subFctStatus
update serialize instruction
add eno handling
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
19.01.2020Insert documentation