Click or drag to resize

MLCount Function

X#
Count the number of lines in a string.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION MLCount(
	cString,
	nLineLength,
	nTabsize,
	lWrap
) AS DWORD CLIPPER
Request Example View Source

Parameters

cString (Optional)
Type: Usual
The string to count.
nLineLength (Optional)
Type: Usual
The number of characters per line, ranging from 4 to 254.
The default line length is 79.
nTabsize (Optional)
Type: Usual
lWrap (Optional)
Type: Usual
Controls whether words wrap to the next line: TRUE if they wrap; FALSE if they do not.
The default is TRUE.

Return Value

Type: DWord
The number of lines in cString, depending on the nLineLength, the nTabSize, and whether word wrapping is on or off.
Remarks
MLCount() is a memo function used with MemoLine() to print strings and memo fields based on the number of characters per line. In the basic operation, use MLCount() to return the number of lines in the string.
Then, using MemoLine() to extract each line, loop through the string until there are no lines left. If lWrap is TRUE and an end of line position breaks a word, it is word-wrapped to the next line and the next line begins with that word.
If lWrap is FALSE, MLCount() counts the number of characters specified by nLineLength as the current line.
The next line begins with the character following the next hard or soft carriage return. Intervening characters are ignored.
Examples
This example displays the contents of each Notes memo field in the SALES database file, 1 line at a time:
X#
 1USE sales NEW
 2nLineLength = 65
 3DO WHILE !EOF()
 4    nLines = MLCount(Sales->Notes, nLineLength)
 5    FOR nCurrLine = 1 UPTO nLines
 6        ? MemoLine(Sales->Notes, nLineLength, nCurrLine)
 7    NEXT
 8    SKIP
 9    ?
10ENDDO
See Also