| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Pads a character string on the left.
PadLeft( <cString>, ;
<nLength>, ;
[<xChar>] ) --> cResult
The function fills <cString> on the left side with <xChar> up to the length <nLength> and returns the result. If <nLength> is smaller than Len(<cString>) the string is truncated on the left side.
| See also: | Center(), PadC() | PadL() | PadR(), PadRight() |
| Category: | CT:String manipulation , Character functions |
| Source: | ct\ctpad.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example outlines the difference between PadL() and PadLeft()
// when the padding length is smaller that the string length.
PROCEDURE Main
LOCAL cString := "12345"
? PadL( cString, 3 ) // result: 123
? PadLeft( cString, 3 ) // result: 345
? PadL( cString, 7, "_" ) // result: __12345
? PadLeft( cString, 7, "_" ) // result: __12345
RETURN
http://www.xHarbour.com