Contains

TwinCAT TIA
Tools String functions

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

Checks if a text occurs in another text and returns the result.

Parameters:

    Value
    The text to search for in ContainString.
    IgnoreCase
    A boolean variable that specifies whether or not case should be ignored in the search.

Returns:

    Contains
    A structure variable of the OpcMethodReturnValueBoolean type. The Result property contains the command-specific return values.
      Result
      A boolean variable that indicates whether the text being searched for is contained in ContainString.

Examples:

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

Beckhoff parameter:

    bStringContains
    A boolean variable that can be used to trigger the execution of the Contains command.
    OutputDataStringContains
    An instance of the "ST_BoolOutputData" structure into which the return value of the Contains method is written.
    hrStringContains
    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.
    ContainString
    The text in which the value Value is searched for.
    ContainStringLength
    The length of the string to search in.
    Value
    The text to search for in ContainString.
    ValueLength
    The length of the string to search for.
    IgnoreCase
    A boolean variable that specifies whether or not case should be ignored in the search.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bStringContains    : BOOL;
    OutputDataStringContains : ST_BoolOutputData;
    hrStringContains   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

hrStringContains := fbStringOperations.StringContains(
      bExecute     := bStringContains, 
      ConnectionHandle  := depragSmartConnection.ConnectionHandle,
      ContainString   := 'Ich bin ein String',
      ContainStringLength  := SIZEOF('Ich bin ein String'),
      Value     := 'String',
      ValueLength    := SIZEOF('String'),
      IgnoreCase    := TRUE, 
      OutputData    => OutputDataStringContains);
IF hrStringContains <> S_FALSE THEN 
      bStringContains := 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".