PRB: KEYMATCH Ignores SET DELETED and SET FILTER Settings

Last reviewed: June 27, 1995
Article ID: Q125791
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.6, 2.6a
  • Microsoft FoxPro for MS-DOS, versions 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, versions 2.6, 2.6a

SYMPTOMS

The KEYMATCH() function added to FoxPro in versions 2.6 and later does not adhere to the settings of SET DELETED or SET FILTER.

CAUSE

The FoxPro versions 2.6 and 2.6a for Windows style help file states that KEYMATCH(); "Searches an index file or index tag for an index key and returns true (.T.) if the index key is found." The SET FILTER and SET DELETED commands only affect the table, not the index. Therefore, KEYMATCH() will not adhere to these settings.

RESOLUTION

For KEYMATCH() to acknowledge the settings of SET DELETED or SET FILTER, place the FILTER expression and DELETED setting in the index itself.

For Example, unless the same conditions of the SET FILTER expression and SET DELETED ON are added to the index, the following code will not give the desired results using the KEYMATCH() function. This example is set up to return a .T. using the Customer table where the record is not deleted, and the State is WA or NC:

   USE Customer
   DELETE TAG ALL   && So you can set KEYMATCH to first tag;
                    && Caution: This will delete all tags in Customer.CDX
   INDEX ON State TAG State
   SET DELETED ON
   SET FILTER TO State = "WA" OR State = "NC"
   ? KEYMATCH('WA',1,'Customer')

KEYMATCH()returns a .F., no match was found.

For the above example to return a .T., place the DELETED and FILTER conditions within the FOR clause of the Index expression as in this example:

   USE Customer
   DELETE TAG ALL   && So you can set KEYMATCH to first tag;
                    && Caution: This will delete all tags in Customer.CDX
   INDEX ON State FOR !DELETED() AND (State = "WA" OR State = "NC") ;
      TAG State
   ?KEYMATCH('WA',1,'Customer')

These changes allow KEYMATCH() to recognize if the records have been marked for Deletion and meet the FILTER (STATE="WA" OR STATE="NC") setting.

STATUS

This behavior is by design.


Additional reference words: FoxDos FoxWin 2.60 2.60a FOXHELP.DBF
FOXHELP.HLP
KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.