How to Return the Memo Line Number from a Text Search

ID: Q128541

2.60a WINDOWS

The information in this article applies to:

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

REFERENCES

For more information about searching memo fields, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q117217
   TITLE     : How to Search for Specific Text in a Memo Field

   ARTICLE-ID: Q88891
   TITLE     : Using Dollar Sign ($) Function in FoxBASE+ or FoxPro

   ARTICLE-ID: Q119382
   TITLE     : FILE: Fw1040.exe Basic Concepts of Relational Database
               Design

Additional reference words: FoxWin 2.60a KBCategory: KBSubcategory: FxotherGeneral
Keywords          : kbcode FxotherGeneral 
Version           : 2.60a
Platform          : WINDOWS

Last Reviewed: May 22, 1998