countLinesAdded by IBM on October 10, 2012 | Version 1 (Original)
|Counts the number of lines that a string would occupy a given width, and returns the number of lines. The count assumes that the font is a monospaced font, and that the line wraps at the ends of words, not in the middle of words.
This function is useful for dynamically sizing the items into which a string will be inserted. For example, to insert an entry from a database into a field on a form, dynamically size the height of the field so that all of the text is visible.
Note: The width must be a character-based width and not a pixel-based width.
Table 1. countLines parameters
|string||Literal string or option reference||The original string. Enclose literal strings in double quotation marks; do not enclose option references in quotation marks.|
|width||Positive integer||The width, in monospaced characters, to base the measurement on.|
Returns The number of lines, or empty string if an error occurs.
Example In this example, the height of the field will be set by the number that countLines returns. The calculation is based on a dynamically-generated value and the set width (50) of the field.
<height compute="countLines(value, '50')"></height>