Functions and Directives

Function LTrim() Foundation

Removes blank spaces at the beginning of a character string.

LTrim( <cString> ) --> cTrimString
<cString> is a character string which is copied with blank spaces at the beginning removed.

LTrim() returns a copy of <cString> with all leading blank spaces (Chr(32) only) removed. When <cString> is an empty character string or consists only of blank spaces, the return value is a null string ("").


The character function LTrim() is used for formatting character strings whose first characters consist of blank spaces (Chr(32)). LTrim() is often used when a number is converted to a character string with Str() and this character string is needs further processing without leading blank spaces.

LTrim() resembles the function RTrim() and Trim() which remove the blank spaces at the end of a character string. Another function that removes blank spaces is Alltrim(), which removes blank spaces at the beginning and the end of a character string. The functions LTrim(), RTrim() and Alltrim() are the inverse of the functions PadL(), PadR() and PadC() which insert blank spaces at the beginning, the end, and at the beginning and end of a character string, respectively.

// The example shows various results of the function LTrim(). 


   ? LTrim("   Xbase++")            // result: "Xbase++" 
   ? Str(2)                         // result: "         2" 
   ? Len(Str(2))                    // result: 10 
   ? LTrim(Str(2))                  // result: "2" 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.