Available Operating Systems: All Available Languages: reporting, Maintain | How to: | Example: |
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.
Limit: Using CTRFLD in a styled report (StyleSheets feature) generally negates the effect of CTRFLD unless the item is also styled as a centered element. Also, if you are using CTRFLD on a platform for which the default font is proportional, either use a non‑proportional font, or issue SET STYLE=OFF before running the request.
CTRFLD(string, length, outfield)
where:
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 length of string and outfield in characters, or a field that contains the length. This argument must be greater than 0. A length less than 0 can cause unpredictable results.
outfield
Alphanumeric
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.
In Dialogue Manager, you must specify the format. In Maintain, you must specify the name of the field.
CTRFLD centers LAST_NAME and stores the result in CENTER_NAME:
SET STYLE=OFF
TABLE FILE EMPLOYEE
PRINT LAST_NAME AND COMPUTE
CENTER_NAME/A15 = CTRFLD(LAST_NAME, 15, 'A15');
WHERE DEPARTMENT EQ 'MIS'
END
The output is:
LAST_NAME CENTER_NAME
‑‑‑‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑
SMITH SMITH
JONES JONES
MCCOY MCCOY
BLACKWOOD BLACKWOOD
GREENSPAN GREENSPAN
CROSS CROSS