Compare

TwinCAT TIA
Tools String functions

ns=2;s=DEPRAG Smart/Utilities/StringOperations/Compare

Compares two specified strings and returns an integer indicating their relative lexicographic order.

Parameters:

    StrA
    The first string used for the comparison.
    StrB
    The second string used for the comparison.
    IgnoreCase
    A boolean variable that specifies whether case should be ignored when comparing or not.

Returns:

    Compare
    A structure variable of type OpcMethodReturnValueInt32. The Result property contains the command-specific return values.
      Result
      An Int32 variable indicating the relative lexicographic order between the compared elements.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bStringCompare
    A Boolean variable that can be used to trigger the execution of the Compare command.
    OutputDataStringCompare
    An instance of the "ST_Int32OutputData" structure into which the return value of the Compare method is written.
    hrStringCompare
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbStringOperations
    An instance of the "FB_StringOperations" function block supplied with the DEPRAG Smart library.
    StringOneToCompare
    The first string that will be used for the comparison. The parameter is of type "STRING(80)".
    StringOneToCompareLength
    The length of the first string used for the comparison.
    StringTwoToCompare
    The second string used for the comparison. The parameter is of type "STRING(80)".
    StringTwoToCompareLength
    The length of the second string used for the comparison.
    IgnoreCase
    A boolean variable that specifies whether case should be ignored when comparing or not.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bStringCompare   : BOOL;
    OutputDataStringCompare : ST_Int32OutputData;
    hrStringCompare   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

hrStringCompare := fbStringOperations.StringCompare(
      bExecute      := bStringCompare, 
      ConnectionHandle   := depragSmartConnection.ConnectionHandle,
      StringOneToCompare   := 'Test',
      StringOneToCompareLength := SIZEOF('Test'),
      StringTwoToCompare   := 'test',
      StringTwoToCompareLength := SIZEOF('test'),
      IgnoreCase      := FALSE, 
      OutputData     => OutputDataStringCompare);
IF hrStringCompare <> S_FALSE THEN 
      bStringCompare := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".