xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

PadLeft()

Pads a character string on the left.

Syntax

PadLeft( <cString>, ;
         <nLength>, ;
        [<xChar>]   ) --> cResult

Arguments

<cString>
This is the string to process.
<nLength>
A numeric value indicating the length of the returned string.
<xChar>
This is a single character or its numeric ASCII code that is added at the beginning of <cString>. It defaults to a blank space (Chr(32)).

Return

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.

Info

See also:Center(), PadC() | PadL() | PadR(), PadRight()
Category: CT:String manipulation , Character functions
Source:ct\ctpad.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

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