JavaScript Editor js editor     Web development 

Main Page

Returns a specific line from a Memo field as a character string.

MLINE(В ) is primarily a text processing function; therefore, the results from processing binary values might not be as expected. For example, MLINE(В ) might return different results depending on the SET MEMOWIDTH setting. MLINE(В ) might interpret binary values as line breaks or truncate binary values unexpectedly. It is recommended that you use the ALINES(В ) function instead to manipulate binary values.

MLINE(MemoFieldName, nLineNumber [, nNumberOfCharacters])



Specifies the name of the memo field from which MLINE(В ) returns a line. If the memo field is in a table open in a non-current work area, preface the memo field name with a period and the table alias.

Specifies the number of the line to return from the memo field. If nLineNumber is negative, 0, or greater than the number of lines in the memo field, MLINE(В ) returns an empty string. MLINE(В ) trims any trailing spaces from the line specified with nLineNumber.

Specifies the number of characters from the beginning of the memo field after which MLINE(В ) returns the specified line. The _MLINE system variable is typically used for nNumberOfCharacters. _MLINE is automatically adjusted each time MLINE(В ) is called. In recursive procedures that return lines from large memo fields, you can obtain the best performance by including _MLINE as nNumberOfCharacters. For more information, see _MLINE System Variable.

Return Value

Character or Varbinary. MLINE( ) returns a character string from a specific line in a Memo field. When using MLINE(В ) with binary values, such as Varbinary and Blob, the return value has type Varbinary.


The length and number of the lines in a memo field are determined by the current value of SET MEMOWIDTH (the default line length is 50 characters). If a carriage return is encountered, no additional characters are returned. The current _WRAP setting determines how the memo field line is displayed.

When searching a memo field for a character string, you can use ATLINE(В ) or ATCLINE(В ) to return the line number of the line in which the character string is found. Use this line number in MLINE(В ) to return the contents of the line from the memo field.


In the following example, two methods are used to return lines from a memo field. Two loops use MLINE(В ) to return lines from the memo field. Note the improvement in performance in the second loop when the system variable _MLINE is used in MLINE(В ).

В Copy Code
CREATE TABLE tmemo (name c(10), notes m)
APPEND BLANK                  && Add a record
WAIT WINDOW 'Filling memo field - takes several seconds' NOWAIT
*** Fill the memo field  ***
FOR gnOuterLoop = 1 TO 5         && loop 5 times
   FOR gnAlphabet = 65 TO 75   && letters A to H
      REPLACE notes WITH REPLICATE(CHR(gnAlphabet), 10) ;
         + CHR(13) ADDITIVE

*** Display all lines from the memo field ***
STORE MEMLINES(notes) TO gnNumLines   && Number of lines in memo field
STORE SECONDS( ) TO gnBegin      && Beginning time
FOR gnCount = 1 TO gnNumLines   && Loop for # of lines in memo field
   ? MLINE(notes, gnCount)      && Display each line
? STR(SECONDS( ) - gnBegin, 4, 2) + ' seconds'   && Total time

*** Preferable method using _MLINE in MLINE( ) ***
*** Display all lines from the memo field ***
WAIT 'Press a key to see the preferred method' WINDOW
STORE 0 TO _MLINE             && Reset _MLINE to zero
STORE SECONDS( ) TO gnBegin      && Beginning time
FOR count = 1 TO gnNumLines      && Loop for # of lines in memo field
   ? MLINE(notes, 1, _MLINE)      && Display each line
? STR(SECONDS( ) - gnBegin, 4, 2) + ' seconds'   && Total time
ERASE tmemo.dbf
ERASE tmemo.fpt

See Also

JavaScript Editor js editor     Web development