Insert

TwinCAT TIA
Tools String functions

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

Inserts text at a specified index position into another text and returns the result.

Parameters:

    Value
    The text to be inserted in StringToInsertIn.
    StartIndex
    The zero-based index position in which to insert Value into StringToInsertIn.

Returns:

    Insert
    A structure variable of type OpcMethodReturnValueString. The Result property contains the command-specific return values.
      Result
      A string in which the Value is inserted in StringToInsertIn.

Examples:

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

Beckhoff parameter:

    bStringInsert
    A boolean variable that can be used to trigger the execution of the Insert command.
    OutputDataStringInsert
    An instance of the "ST_StringOutputData" structure into which the return value of the Insert method is written.
    hrStringInsert
    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.
    StringToInsertIn
    The text in which the text from Value should be inserted.
    StringToInsertInLength
    The length of the string in which another string is to be inserted.
    StringToInsert
    The string of type "STRING(80)" inserted into another string.
    StringToInsertLength
    The length of the string that will be inserted into another string.
    StartIndex
    The zero-based index position in which to insert Value into StringToInsertIn.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bStringInsert   : BOOL;
     OutputDataStringInsert : ST_StringOutputData;
     hrStringInsert   : HRESULT;

     fbStringOperations : FB_StringOperations;
END_VAR

hrStringInsert := fbStringOperations.StringInsert(
      bExecute     := bStringInsert, 
      ConnectionHandle  := depragSmartConnection.ConnectionHandle,
      StringToInsertIn  := 'IamATestString',
      StringToInsertInLength := SIZEOF('IamATestString'),
      StringToInsert    := 'Beautiful',
      StringToInsertLength   := SIZEOF('Beautiful'),
      StartIndex    := 4, 
      OutputData    => OutputDataStringInsert);
IF hrStringInsert <> S_FALSE THEN 
      bStringInsert := 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".