xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Center()

Returns a string for centered display.

Syntax

Center( <cString>   , ;
       [<nLength>]  , ;
       [<cPadChar>] , ;
       [<lBothSides>] ) --> cCenteredString

Arguments

<cString>
This is a character string to fill with padding characters.
<nLength>
This optional numeric value specifies the number of characters that fit into one line for display. The default value is MaxCol()+1.
<cPadChar>
A single character used to pad <cString> with. It defaults to a space character (Chr(32)).
<lBothSides>
This parameter defaults to .F. (false) so that <cString> is only filled on the left side up to the length <nLength>. When .T. (true) is passed, the string is padded on the left and right side.

Return

The function returns a string padded with <cPadChar> that displays centered.

Description

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.

Info

See also:PadLeft(), PadRight()
Category: CT:String manipulation , Character functions
Source:ct\ctmisc.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

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

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