xHarbour Reference Documentation > Function Reference |
Pads values of data type Character, Date and Numeric with a fill character.
PadC( <expression>, <nLength>, [<cFillChar>] ) --> cPaddedString PadL( <expression>, <nLength>, [<cFillChar>] ) --> cPaddedString PadR( <expression>, <nLength>, [<cFillChar>] ) --> cPaddedString
The function returns a character string of <nLength> characters. It contains the value of <expression> padded with <cFillChar>. If the value of <expression> contains more than <nLength> characters, the value in the returned string is truncated to <nLength> characters.
PadC(), PadL(), and PadR() are conversion functions that convert the value of an expression to a character string, padded with a fill character. The functions accept for <expression> values of data type Character, Date and Numeric.
PadC() | The fill character is added on the left and the right side, so that the value of <expression> appears centered in the result string. |
PadL() | The fill character is added on the left side, so that the value of <expression> appears right justified in the result string. |
PadL() | The fill character is added on the right side, so that the value of <expression> appears left justified in the result string. |
Note: function Pad() is a synonym for PadR().
See also: | Alltrim(), LTrim(), RTrim(), StrTran(), Stuff(), SubStr() |
Category: | Character functions , Conversion functions |
Source: | rtl/pad.c, rtl/padc.c, rtl/padl.c, rtl/padr.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows the results of creating padded character strings PROCEDURE Main ? PadC( "xHarbour", 12, "_" ) // result: __xHarbour__ ? PadL( "xHarbour", 12, "_" ) // result: ____xHarbour ? PadR( "xHarbour", 12, "_" ) // result: xHarbour____ ? "0x" + PadL( 2, 4, "0" ) // result: 0x0002 RETURN
http://www.xHarbour.com