Function MlCount() Foundation

Determines the number of lines in a character string or memo field.

Syntax
MlCount( <cString>  , ;
        [<nLineLen>], ;
        [<nTabSize>], ;
        [<lWrap>]     ) --> nLineCount
Parameters
<cString>
<cString> is a character string expression or memo field whose line count is returned.
<nLineLen>
<nLineLen> is an integer numeric value specifying the maximum length of a line in <cString>. The default is 79 characters per line.
<nTabSize>
<nTabSize> indicates the tab size. The default value is 4 characters per tab. The tab size can be a maximum value of <nLineLen> - 1.
<lWrap>
The logical value <lWrap> specifies whether automatic word wrap is taken into consideration. The default value is .T. (true) which indicates that automatic word wrap should be taken into consideration. When the value .F. (false) is specified, word wrap is not taken into consideration.
Return

MlCount() returns the total number of lines in <cString> as an integer. The number of lines depends on the formatting specified by the line length <nLineLen>, tab size <nTabSize>, and word wrap <lWrap> arguments.

Description

The memo function MlCount() determines the number of lines in a formatted character string based on the number of characters per line. It is often used with the function MemoLine() to extract text line by line.

If automatic word wrap is taken into consideration (.T. is passed for <lWrap>), the last word in a line is wrapped to the next line if it does not fit completely on the current line. When <lWrap> contains the value .F., lines are defined by the presence of a hard return (Chr(13)+Chr(10)).

Examples
MlCount()
// In the example, the number of printed pages required 
// to print all entries for the memo field "Memo" is 
// determined. 

PROCEDURE Main 
   LOCAL nLineLen := 60 
   LOCAL nEntries := 0 , nTotal := 0 

   USE Address NEW 

   DO WHILE .NOT. Eof() 
      IF ! Empty( Address->Memo ) 
         nEntries ++ 
         nTotal   += MlCount( Address->Memo, nLineLen ) 
      ENDIF 
      SKIP 
   ENDDO 

   ? "Total memos:", nEntries 
   ? "Print pages:", Int( nTotal / 63 ) 

   USE 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.