Microsoft KB Archive/139092

{| = FIX: "Invalid Subscript Reference" Error If UDF in SET FILTER =
 * width="100%"|

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 Version          : 2.60a Platform         : WINDOWS Solution Type    : kbfix
 * }