Rtrim

Syntax:

    stringvar = Rtrim(stringvar)

Command Availability:

Available on all microcontrollers.

Explanation:

The Rtrim function trims the 7-bit ASCII space character (value 32) from the right-hand side of a string.

Use Rtrim on text you have received from another source that may have irregular spacing at the right-hand end of the string.

Example:

    Dim TestData As String
    TestData = "Hello   "

    TestData = RTRIM(TestData)          ' <<< the RTRIM instruction
    ' TestData now holds "Hello", with the trailing spaces removed

Key line: RTRIM(TestData) — removes only the trailing spaces from TestData, leaving any spaces at the start untouched.

See Also:

  • Trim — trimming both ends at once
  • Ltrim — trimming only the left-hand side