Creates local variables and variable arrays. There are two versions of the syntax.
LOCAL Var1 [ AS type [ OF ClassLib ] ] | [ ArrayName1( nRows1 [, nColumns1 ] ) [ AS type [ OF ClassLib ] ] ] [, Var2 [ AS type [ OF ClassLib ] ] | [, ArrayName2( nRows2 [, nColumns2 ] ) [ AS type [ OF ClassLib ] ] ] |
LOCAL [ ARRAY ] ArrayName1( nRows1 [, nColumns1 ] ) [ AS type [OF ClassLib ] ] [, ArrayName2( nRows2 [, nColumns2 ] ) [ AS type [ OF ClassLib ] ] ] |
Parameters
- LOCAL VarList
- Specifies one or more local variables to create. Use commas to separate multiple items in VarList. The single letters A through J and M are reserved and cannot be used as variable names.
- [ ARRAY ] ArrayName1( nRows1[, nColumns1 ] ) [, ArrayName2( nRows2[, nColumns2 ] ) ] ...
- Specifies one or more local arrays to create. For more information about arrays, see DIMENSION Command.
- [ AS type[ OF ClassLib] ]
- Specifies the data type of the variable or array and the class library containing the type description of type on which this variable or array is based. When you specify a valid class name, Visual FoxPro uses the type library, if you specify a ProgID Property (Visual FoxPro), or instantiates an object to get a list of properties, methods, and events. If the specified class name is not found, Visual FoxPro displays a list box of available classes. You can use the AS clause to implement strong typing. IntelliSense functionality is available for object and variable references only when they are strongly typed. For more information, see How to: Implement Strong Typing for Class, Object, and Variable Code.
Remarks
You can use and modify local variables and variable arrays only within the procedure or function in which they are created and cannot be accessed by higher or lower-level programs. After the procedure or function containing the local variables and arrays completes execution, local variables and arrays are released.
Variables and arrays created with LOCAL are initialized to False (.F.).
You must declare any variables or arrays that you want local prior to assigning values to them. If you assign a value to a variable or array in a program and later declare it as local using LOCAL, Visual FoxPro generates a syntax error.
You can pass local variables by reference.
You cannot abbreviate LOCAL because LOCAL and LOCATE have the same first four letters.