Microsoft KB Archive/128541

{| = How to Return the Memo Line Number from a Text Search =
 * width="100%"|

ID: Q128541

2.60a WINDOWS

The information in this article applies to:


 * Microsoft FoxPro for Windows, version 2.6a

SUMMARY
There is no single function that will return the line number on which a particular search item is located in a memo field. This article shows by example how to do it in code.

MORE INFORMATION
Here is the sample code:

&& Start of the program.

msearch = 'The search item' LINENO = 0 && variable to keep track of the current line number x = 0     && variable to count the number of occurrences of search item mquit = .T.  moccur=1   && moccur is the number of occurrences

DO WHILE mquit LINENO = LINENO +1 IF msearch $ MLINE(memo1,LINENO) &&memo1 is the memo field x = x + 1 ENDIF IF x=moccur OR LINENO = MEMLINES(memo1)+1 mquit = .F.     ENDIF ENDDO

IF LINENO < MEMLINES(memo1)+1 WAIT WINDOW STR(LINENO) ELSE WAIT WINDOW "Not found" ENDIF