PRB: Attempt to Use FoxPro Function As an Array

Last reviewed: June 28, 1995
Article ID: Q115700
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SYMPTOMS

The compiler produces the error message "Attempt to use FoxPro function as an array" when you are compiling dBASE IV code in FoxPro.

CAUSE

FoxPro 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]

RESOLUTION

Rename 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 INFORMATION

The 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
2.50c
errmsg
err msg
parens parenthesis
KBCategory: kbprg kberrmsg kbprb
KBSubcategory: FxinteropDbase


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