FIX: "Invalid Subscript Reference" Error If UDF in SET FILTER

Last reviewed: October 29, 1997
Article ID: Q139092
2.60a WINDOWS kbprg kbbuglist kbfixlist

The information in this article applies to:

  • Microsoft FoxPro for Windows, version 2.6a

SYMPTOMS

The error message "Invalid Subscript Reference" appears when you use a UDF (user defined function) in a SET FILTER expression.

CAUSE

FoxPro 2.x does not allow UDF calls to be used in a SET FILTER expression.

WORKAROUND

Upgrade to Microsoft Visual FoxPro version 3.0 or do not use a UDF in a SET FILTER expression. If the logic in the UDF is simple, it can be incorporated directly into the SET FILTER condition. If the logic in the UDF is too complex to be incorporated into the SET FILTER expression, use a different approach to process a subset of the records such as the SELECT - SQL command or SCAN.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro version 3.0.

MORE INFORMATION

This behavior is not affected by the SET COMPATIBLE setting. In dBASE IV, it is possible to use a UDF in a SET FILTER expression. The UDF will function as expected, and no error messages will be returned.

Steps to Reproduce Problem

The following code produces a "Invalid Subscript Reference" error message when used in FoxPro. When used in dBASE IV, no errors occur. The LIST command produces a single record with the value of "BB."

   CREATE TABLE test (one C(2))
   INSERT INTO test (one) VALUES ("AA")
   INSERT INTO test (one) VALUES ("BB")
   INSERT INTO test (one) VALUES ("CC")
   INSERT INTO test (one) VALUES ("DD")

   SET FILTER TO myudf()

   LIST

   FUNCTION myudf
     retval = .F.
     IF one = "BB"
        retval = .T.
     ENDIF
   RETURN(retval)


Additional reference words: 2.60a FoxWin VFoxWin fixlist3.00 buglist2.60a
KBCategory: kbprg kbbuglist kbfixlist
KBSubcategory: FxprgSet
Keywords : FxprgSet kbbuglist kbfixlist kbprg
Version : 2.60a
Platform : WINDOWS
Solution Type : kbfix


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: October 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.