CENTER( )
Returns a character string that contains a string centered in a line of specified length.
Syntax
CENTER(<expC> [, <length expN> [, <pad expC> ]])
<expC>
The text to center.
<length expN>
The length of the resulting line of text. The default is 80 characters.
<pad expC>
The single character to pad the string with if <length expN> is greater than the number of characters in <expC>. If <length expN> is equal to or less than the number of characters in <expC>, <pad expC> is ignored.
If <pad expC> is more than one character, CENTER( ) uses only the first character. If <pad expC> isn't specified, CENTER( ) pads with spaces.
Description
CENTER( ) returns a character expression with the requisite number of leading and trailing spaces to center it in a line that is a specified number of characters wide.
To create the resulting string, CENTER( ) performs the following steps.
Subtracts the length of <expC> or <memo field> from <length expN>
Divides the result in half and rounds up if necessary
Pads <expC> on either side with that number of spaces or the first character in <pad expC>
If the length of <expC> or <memo field> is greater than <length expN>, CENTER( ) does the following:
Subtracts <length expN> from the length of <expC>
Divides the result in half and rounds up if necessary
Truncates both sides of <expC> by that many characters
When the result of subtracting the length of <expC> from <length expN> is an odd number, CENTER( ) pads one less space on the left if the difference is positive, or truncates one less character on the left if the difference is negative.