| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Returns a string for centered display.
Center( <cString> , ;
[<nLength>] , ;
[<cPadChar>] , ;
[<lBothSides>] ) --> cCenteredString
The function returns a string padded with <cPadChar> that displays centered.
Center() fills a string with <cFillCharacter> so it is centered within a space of <nLength> characters. By default the string is only filled to the left. If <nLength> is not specified the string will be centered between the current cursor position and MaxCol()+1.
| See also: | PadLeft(), PadRight() |
| Category: | CT:String manipulation , Character functions |
| Source: | ct\ctmisc.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example displays a series of character strings centered
// on a 40 column wide area of the screen and fills the remainder
// with dots.
PROCEDURE Main
LOCAL aLine := { "The", "xHarbour", "compiler", "is", "more!" }
LOCAL cLine
CLS
FOR EACH cLine IN aLine
? Center( cLine, 40, ".", .T. )
NEXT
** result:
// ..................The...................
// ................xHarbour................
// ................compiler................
// ...................is...................
// .................more!..................
RETURN
http://www.xHarbour.com