StartsWith

TwinCAT TIA
Tools String functions

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

Checks if a text starts with a certain value.

Parameters:

    Value
    The text that will be checked at the beginning of ContainString.
    IgnoreCase
    A boolean variable that specifies whether case should be ignored when comparing or not.

Returns:

    StartsWith
    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 to search for occurs at the beginning of the ContainString parameter.

Examples:

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

Beckhoff parameter:

    bStringStartsWith
    A boolean variable that can be used to trigger the execution of the StartsWith command.
    OutputDataStringStartsWith
    An instance of the "ST_BoolOutputData" structure into which the return value of the StartsWith method is written.
    hrStringStartsWith
    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 to be searched in.
    ContainStringLength
    The length of the string to search in.
    Value
    The text that will be checked at the beginning of ContainString.
    ValueLength
    The length of the string to be compared with the beginning of the string to be searched in.
    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
    bStringStartsWith   : BOOL;
    OutputDataStringStartsWith : ST_BoolOutputData;
    hrStringStartsWith   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

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