xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

RTrim()

Removes trailing blank spaces from a character string.

Syntax

RTrim( <cString> [,<lAllWhiteSpace>] ) --> cTrimmedString
Trim( <cString> [,<lAllWhiteSpace>] ) --> cTrimmedString

Arguments

<cString>
A character string which is copied without trailing blank space characters.
<lAllWhiteSpace>
This parameter defaults to .F. (false). If .T. (true) is passed, function RTrim() treats the white-space characters TAB (Chr(9)) and CRLF (Chr(13)+Chr(10)) like blank spaces and removes them as well.

Return

The function returns a copy of <cString> without blank spaces at the end of the string.

Description

RTrim() is used for formatting character strings whose ending characters consist of blank spaces (Chr(32)). The function creates a copy of <cString> but ignores blank spaces at the end of the input string. It is frequently used to format character strings stored in database fields. Such strings are padded with blank paces up to the field length.

Note()  function Trim() is a synonym for RTrim().

Info

See also:Alltrim(), LTrim(), PadC() | PadL() | PadR(), SubStr()
Category: Character functions
Source:rtl\trim.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows various possibilities for trimming a string.

   #define CRLF     Chr(13)+Chr(10)

   PROCEDURE Main
      LOCAL cStr  := "  xHarbour    "

      ? Len( cStr )                   // result:  14
      ? Len( LTrim( cStr ) )          // result:  12
      ? Len( RTrim( cStr ) )          // result:  10
      ? Len( AllTrim( cStr ) )        // result:   8

      cStr := "xHarbour  " + CRLF

      ? Len( cStr )                   // result:  12
      ? Len( RTrim( cStr ) )          // result:  12
      ? Len( RTrim( cStr, .T. ) )     // result:   8

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe