Substring

TwinCAT TIA
Tools String functions

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

Returns the part of the specified text starting from a passed index position.

Parameters:

Returns:

    Substring
    A structure variable of type OpcMethodReturnValueString. The Result property contains the command-specific return values.
      Result
      The partial text from the parameter ContainString from the index position StartIndex to the end of the text.

Examples:

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

Beckhoff parameter:

    bStringSubstring
    A boolean variable that can be used to trigger the execution of the Substring command.
    OutputDataStringSubstring
    An instance of the "ST_StringOutputData" structure into which the return value of the Substring method is written.
    hrStringSubstring
    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.
    ContainStringLength
    The length of the string from which the substring is to be extracted.
    StartIndex
    The zero-based index for the initial position.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bStringSubstring   : BOOL;
    OutputDataStringSubstring : ST_StringOutputData;
    hrStringSubstring   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

hrStringSubstring := fbStringOperations.StringSubstring(
      bExecute     := bStringSubstring, 
      ConnectionHandle  := depragSmartConnection.ConnectionHandle,
      ContainString   := 'Ich bin ein String',
      ContainStringLength  := SIZEOF('Ich bin ein String'),
      StartIndex    := 5, 
      OutputData    => OutputDataStringSubstring);
IF hrStringSubstring <> S_FALSE THEN 
      bStringSubstring := 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".