CTRFLD: Centering a Character String

How to:

The CTRFLD function centers a character string within a field. The number of leading spaces is equal to or one less than the number of trailing spaces.

CTRFLD is useful for centering the contents of a field and its report column, or a heading that consists only of an embedded field. HEADING CENTER centers each field value including trailing spaces. To center the field value without the trailing spaces, first center the value within the field using CTRFLD.


Top of page

x
Syntax: How to Center a Character String
CTRFLD(source_string, length, output)

where:

source_string

Alphanumeric

Is the character string enclosed in single quotation marks, or a field or variable that contains the character string.

length

Integer

Is the number of characters in source_string and output. This argument must be greater than 0. A length less than 0 can cause unpredictable results.

output

Alphanumeric



Example: Centering a Field

CTRFLD centers LAST_NAME and stores the result in a column with the format A12:

CTRFLD(LAST_NAME, 12, 'A12')

iWay Software