Boxing memo's Boxing Word-Wrapped Fields (#1 - approximate)
Determining approximate number of lines
An easy but approximate way to calculate the number of lines occupied by a
word-wrapped field is to test the field to see how many characters it
contains, to divide the number of characters by the field width (also in
characters), and to round up the result.
R&R provides two functions that enable you to find out how many characters
of data are contained in a character field:
■ LEN
returns the length of a character field, counting trailing spaces
■ TRIM
Removes trailing spaces from a character expression
Using these two functions, you can create an expression that returns the
number of characters contained in any character field. For a character
field called CFIELD, the expression would be as follows:
len(trim(CFIELD))
When R&R evaluates this expression, it first trims trailing spaces (if
any) from the CFIELD field; then it calculates the remaining number of
characters in the field.
The next step is to divide the value returned by this expression by the
width of the field in characters and to round this result up. The
following expression for a calculated field we will call LENGTH performs
these functions. In this expression, "Width" represents the width of
CFIELD in the report layout.
int((len(trim(CFIELD)) + (Width - 1))) / Width