Function MemoLine() Foundation

Extracts text lines from a character string or from a memo field.

Syntax
MemoLine( <cString>   , ;
         [<nLineLen>] , ;
         [<nLine>]    , ;
         [<nTabSize>] , ;
         [<lWrap>]      ) --> cLine
Parameters
<cString>
<cString> is a character string or the contents of a memo field from which a text line is extracted.
<nLineLen>
<nLineLen> is a positive integer value specifying the maximum line length for <cString>. The default is 79 characters per line.
<nLine>
<nLine> specifies the position of the line to extract within the text. By default the first line in the text is extracted.
<nTabSize>
<nTabSize> indicates the tab size. The default value is 4 characters per tab. The tab can accept a maximum value of <nLineLen> - 1.
<lWrap>
The logical value <lWrap> specifies whether automatic word wrapping is taken into consideration when retrieving the line of text. The default value is .T. (true). When the value .F. (false) is specified, word wrap is not taken into consideration.
Return

MemoLine() extracts the line specified with <nLine> from the text <cString>. When the extracted string is shorter than <nLineLen> the character string is padded with blank spaces to the length <nLineLen>. When <nLine> contains a value which is greater than the entire number of lines in <cString>, a null string ("") is returned. If automatic word wrap is taken into consideration (by specifying .T. for <lWrap>), the last word in a line is treated as moved to the next line if it does not fit completely in the extracted line. If <lWrap> contains the value .F., entire lines are always extracted up to a hard return (Chr(13)+Chr(10)) and the first <nLineLen> characters are returned.

Description

The memo function MemoLine() extracts character strings from text. It is comparable to the function SubStr(), but works on the basis of entire lines. MemoLine() is often used with the memo function MlCount() which determines the total number of lines in the text. MemoLine() returns a text line without formatting characters like tab (Chr(9)) and return (Chr(13)+Chr(10)).

Examples
MemoLine()

// In the example, a file is read and the individual lines 
// in the file are written to an array. This might be used 
// to process configuration files in an Xbase++ program. 

FUNCTION ReadSysData( cSysFilename ) 
   LOCAL cText     := MemoRead( cSysFilename ) 
   LOCAL nMaxLines := MlCount( cText, 80 ) 
   LOCAL aLines[ nMaxLines ], n 

   FOR n:=1 TO nMaxLines 
      aLines[ n ] := Trim( MemoLine( cText, 80, n ) ) 
   NEXT 

RETURN aLines 
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.