PRB: Cannot Use LOCAL Variables as ArraysID: Q131465 3.00 WINDOWS kbprg kbprb The information in this article applies to:
SYMPTOMSOnce a variable is declared as LOCAL, it cannot be used as an array. For example, if the AFIELDS() function is used as follows, the error " <var> is not an array" is displayed. However, if the PRIVATE keyword is used instead of LOCAL, no error is generated. This is because PRIVATE does not declare variables.
CAUSEThe error "<var> is not an array" occurs bacause the variable has been declared as a non array variable. The PRIVATE and LOCAL commands perform different tasks. The PRIVATE command hides memory variables. However, it does not create them. In the example shown above, the AFIELDS() function created the array variable aFields(2), not the PRIVATE command. On the other hand, the LOCAL command, like the PUBLIC command, creates memory variables and defines a scope for them. The LOCAL command is new to Visual FoxPro. It creates memory variables and array memory variables that can be used and modified only within the procedure or function in which they are created. They cannot be accessed by higher or lower level programs. For more information about the LOCAL command, search for LOCAL in the Visual FoxPro Help menu.
RESOLUTIONUse LOCAL ARRAY to declare an array memory variable. For example:
STATUSThis behavior is by design. Additional reference words: 3.00 VFoxWin KBCategory: kbprg kbprb KBSubcategory: FxprgGeneral
|
Last Reviewed: May 1, 1996 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |