PRB: Attempt to Use FoxPro Function As an ArrayLast reviewed: June 28, 1995Article ID: Q115700 |
The information in this article applies to:
SYMPTOMSThe compiler produces the error message "Attempt to use FoxPro function as an array" when you are compiling dBASE IV code in FoxPro.
CAUSEFoxPro allows square brackets or parentheses to be used with arrays or functions. dBASE does not allow brackets and parentheses to be used interchangeably. FoxPro will therefore produce this error message if the name of a FoxPro function (or reserved word) is used as the name of an array. For example, the following code produces the error in FoxPro:
DECLARE abs[1,1] RESOLUTIONRename the array so its name does not conflict with the name of an existing FoxPro function. For example, change this statement
DECLARE abs[1,1]to this:
DECLARE newabs[1,1]Since there is no FoxPro function named "newabs", a compiler error is not generated when the code is compiled. For a list of FoxPro keywords, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q96293 TITLE : Keywords for FoxPro 2.0 and 2.5 MORE INFORMATIONThe following statements are valid in FoxPro:
? myfunc("hello") ? myfunc["hello"] DECLARE myarray(1,1) DECLARE myarray[1,1]dBASE IV does not allow brackets to be used with functions and does not allow parentheses to be used with arrays. The following statements are valid in dBASE IV 2.0:
? myfunc("hello") DECLARE myarray[1,1]The following statements are not valid in dBASE IV 2.0:
? myfunc["hello"] DECLARE myarray(1,1)Since dBASE does not allow brackets and parentheses to be used interchangeably, dBASE can determine whether a statement is referring to an array or a function by the type of brackets used in the statement. Since FoxPro does allow brackets and parentheses to be used interchangeably, FoxPro cannot determine whether a statement refers to an array or a function. Therefore, when the FoxPro compiler encounters an expression that refers to an array with the same name as a FoxPro function, the compiler assumes the statement refers to the FoxPro function and generates an appropriate error message. This problem can be demonstrated with the following statement:
DECLARE abs[1,1]This statement will compile under dBASE IV without error, but will not compile under FoxPro. If the "Attempt to use FoxPro function as an array" error message occurs when you are compiling dBASE IV code, and the dBASE IV compiler does not produce an error message when compiling the code, an array whose name conflicts with the name of a FoxPro function might be used in the code.
|
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. |