TEXTFILL

The TEXTFILL function reformats a text value to fit compactly into lines of a specified width, regardless of its current format. TEXTFILL is commonly used to reformat text with an unnecessarily ragged right margin or with a bad line width.

Return Value

TEXT or NTEXT

Syntax

TEXTFILL(text-expression, width)

Arguments

text-expression

A text expression to be reformatted to the specified width, regardless of the current format of the data. When you specify a TEXT expression, the return value is TEXT. When you specify an NTEXT expression, the return value is NTEXT.

width

The desired width of the reformatted data, entered as an integer value from 1 to 132.

In a structured report, TEXTFILL reformats text-expression to the width you specify, as long as that width is less than the width of the report column. When width is greater than the column width, it is ignored by TEXTFILL, and the expression is reformatted to the width of the column.

How Words are Handled

TEXTFILL fits as many words of text-expression as it can onto one line, placing just one space between words and removing extra spaces between words. When a word is longer than width, TEXTFILL breaks it across two or more lines. In this case there may be extra spaces at the end of lines.

Permanent Reformatting

Rather than repeatedly reformatting a specific text variable, you can permanently format it by assigning the result of the TEXTFILL function to the same text variable, as shown in the following example.

textvar = TEXTFILL(textvar 12)

Examples

Example 23-13 The Effects of TEXTFILL on ROW

The following example shows the effect of TEXTFILL on a ROW command, using the nicely formatted text variable textvar.

The statement

SHOW textvar

produces the following output.

You can use the following options to control the format of
your display.
BMARGIN Controls the bottom margin.
COLWIDTH Controls column width.
COMMAS Controls the use of commas in numbers.
DECIMALS Controls number of decimal places in numbers.
LSIZE Controls the maximum length of a line.
NASPELL Controls the spelling of NA values in output.

The ROW command

ROW W 50 textvar

produces the following output.

You can use the following options to control the
format of your
display.
BMARGIN Controls the bottom margin.
COLWIDTH Controls column width.
COMMAS Controls the use of commas in
numbers.
DECIMALS Controls the number of decimal
places in numbers.
LSIZE Controls the maximum length of a
line.
NASPELL Controls the spelling of NA values
in output.

By contrast, the ROW command with TEXTFILL

ROW W 50 TEXTFILL(textvar, 50)

produces the following output.

You can use the following options to control the
format of your display. BMARGIN Controls the
bottom margin. COLWIDTH Controls column width.
COMMAS Controls the use of commas in numbers.
DECIMALS Controls the number of decimal places in
numbers. LSIZE Controls the maximum length of a
line. NASPELL Controls the spelling of NA values
in output.