How to Return the Memo Line Number from a Text Search

Last reviewed: February 12, 1998
Article ID: Q128541
2.60a WINDOWS kbprg kbcode

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

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: kbprg kbcode
KBSubcategory: FxotherGeneral
Keywords : FxotherGeneral kbcode kbprg
Version : 2.60a
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 12, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.