xHarbour Reference Documentation > Function Reference |
Removes trailing blank spaces from a character string.
Trim( <cString> [,<lAllWhiteSpace>] ) --> cTrimmedString RTrim( <cString> [,<lAllWhiteSpace>] ) --> cTrimmedString
The function returns a copy of <cString> without blank spaces at the end of the string.
Trim() 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 RTrim() is a synonym for Trim().
See also: | Alltrim(), LTrim(), PadC() | PadL() | PadR(), SubStr() |
Category: | Character functions |
Source: | rtl\trim.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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( Trim ( cStr ) ) // result: 10 ? Len( AllTrim( cStr ) ) // result: 8 cStr := "xHarbour " + CRLF ? Len( cStr ) // result: 12 ? Len( Trim( cStr ) ) // result: 12 ? Len( Trim( cStr, .T. ) ) // result: 8 RETURN
http://www.xHarbour.com