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( ).
CLEAR
SET TALK OFF
SET MEMOWIDTH TO 50
CLOSE DATABASES
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
NEXT
NEXT
*** 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
NEXT
? 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
CLEAR
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
NEXT
? STR(SECONDS( ) - gnBegin, 4, 2) + ' seconds' && Total time
SET TALK ON
CLOSE DATABASES
ERASE tmemo.dbf
ERASE tmemo.fpt