SubstringWithLength

TwinCAT TIA
Tools String functions

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

Returns a part of the specified text. The part starts from the Startindex parameter and ends at Startindex+Length.

Parameters:

    StartIndex
    The zero-based index for the initial position in ContainString.
    Length
    The length of the characters to be read.

Returns:

    SubstringWithLength
    A structure variable of type OpcMethodReturnValueString. The Result property contains the command-specific return values.
      Result
      The partial text from 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:

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


VAR
    bStringSubstringWithLength   : BOOL;
    OutputDataStringSubstringWithLength : ST_StringOutputData;
    hrStringSubstringWithLength   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

hrStringSubstringWithLength := fbStringOperations.StringSubstringWithLength(
      bExecute     := bStringSubstringWithLength, 
      ConnectionHandle  := depragSmartConnection.ConnectionHandle,
      ContainString   := 'Ich bin ein String',
      ContainStringLength  := SIZEOF('Ich bin ein String'),
      StartIndex    := 8,
      Length     := 3, 
      OutputData    => OutputDataStringSubstringWithLength);
IF hrStringSubstringWithLength <> S_FALSE THEN 
      bStringSubstringWithLength := 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".