[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
CENTER()
Centers a string using pad characters
------------------------------------------------------------------------------
Syntax
CENTER(<cString>,[<nLength>],[<cPadCharacter>],
[<lMode>]) --> cString
Arguments
<cString> Designates the character string that you choose to
center.
<nLength> Designates the length of the line within which the
<cString> sequence is centered.
<cPadCharacter> Designates the character with which the <cString>
sequence is centered. The default character is a space.
<lMode> Designates whether only the beginning, or both sides of
<cString> are padded. The default value (.F.) only fills the beginning.
Returns
The processed string is returned.
Description
The CENTER() function provides a simple way to center text in any line.
CENTER() is able to pad only on the left or on the left and right using
any selected character. Leading and trailing blanks (if any) are
replaced with the new character.
When <nLength> is not specified, CENTER() assumes the maximum available
line width to be MAXCOL() + 1, so that the correct output appears in the
windows. Additionally, the current cursor position or the column
position selected through a SAY command is also noted. So, if there is
an output on an 80-column line that begins at column 20, a section of 40
characters from column 20 is used to center the output.
Note
. If the sum of the pad characters is odd, then one more
character is inserted at the beginning of the character string.
Examples
. Center the output with an available line length of 10, and
insert the leading characters:
? CENTER("xx", 10) // " xx"
. Fill on the left and on the right:
? CENTER("xx", 10, .T.) // " xx "
. When characters that match the <cPadCharacter> are present,
these characters are removed prior to centering:
? CENTER("xx ", 10, .T.) // " xx "
. Fill with other characters:
? CENTER("xx", 10, ".") // "....xx"
? CENTER("xx", 10, ".", .T.) // "....xx...."
? CENTER("x", 10, ".", .T.) // ".....x...."
. In the following example, the "X" is intended to represent a
40-character wide screen. The string "CLIPPER" is centered there
with the "." character, starting at position 10:
@@ 1, 10 SAY CENTER("CLIPPER", ".", .T.)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXX.......CLIPPER......XXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
See Also:
PADLEFT()
PADRIGHT()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson