PRB: UDF in SET FILTER TO Error: Invalid Subscript ReferenceLast reviewed: June 28, 1995Article ID: Q116032 |
The information in this article applies to:
SYMPTOMSUsing a user-defined function (UDF) in a SET FILTER expression causes the error message "Invalid Subscript Reference" to occur.
CAUSEFoxPro does not allow a UDF to be used in a SET FILTER expression.
RESOLUTIONTo avoid this problem, do not use a UDF in a SET FILTER expression. 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 the SCAN command.
STATUSThis behavior is by design.
MORE INFORMATIONIn dBASE IV, you can use a UDF in a SET FILTER expression. The UDF will function as expected, and no error messages will be returned. In FoxPro, however, this situation will result in the error message "Invalid Subscript Reference." This behavior is not affected by the setting of SET COMPATIBLE.
Steps to Reproduce ProblemThe following code produces a "Invalid Subscript Reference" error message when executed in FoxPro. When this code is executed in dBASE IV, no errors will occur. The LIST command will produce one 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: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |