Microsoft KB Archive/131465

= PRB: Cannot Use LOCAL Variables as Arrays =

Article ID: 131465

Article Last Modified on 2/15/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q131465



SYMPTOMS
Once 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 " 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. LOCAL aFields1 PRIVATE aFields2 USE SYS(2004)+"\SAMPLES\DATA\CUSTOMER" n = AFIELDS(aFields1) n = AFIELDS(aFields2)



CAUSE
The error " 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.



RESOLUTION
Use LOCAL ARRAY to declare an array memory variable. For example: LOCAL ARRAY aTest(3,2)



STATUS
This behavior is by design.

Additional query words: VFoxWin

Keywords: KB131465

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.