Trim

TwinCAT TIA
Tools String functions

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

Removes all white space characters at the beginning and end of the specified text.

Parameters:

    StringToTrim
    The text from which all white space characters are removed at the beginning and end.

Returns:

    Trim
    A structure variable of type OpcMethodReturnValueToolsReturnValue. The Result property contains the command-specific return values.
      Result
      Input parameter StringToTrim without spaces at the beginning and end.

Examples:

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

Beckhoff parameter:

    bStringTrim
    A boolean variable that can be used to trigger the execution of the Trim command.
    OutputDataStringTrim
    An instance of the "ST_StringOutputData" structure into which the return value of the Trim method is written.
    hrStringTrim
    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.
    Value
    The string of type "STRING(80)" from which all white space characters are to be removed.
    ValueLength
    The length of the string from which all white space characters are to be removed.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bStringTrim    : BOOL;
    OutputDataStringTrim : ST_StringOutputData;
    hrStringTrim   : HRESULT;

    fbStringOperations : FB_StringOperations;
END_VAR

hrStringTrim := fbStringOperations.StringTrim(
      bExecute     := bStringTrim, 
      ConnectionHandle  := depragSmartConnection.ConnectionHandle,
      Value     := '    Ich bin ein String',
      ValueLength    := SIZEOF('    Ich bin ein String'), 
      OutputData    => OutputDataStringTrim);
IF hrStringTrim <> S_FALSE THEN 
      bStringTrim := 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".