LOCAL Command

Creates local variables and variable arrays.

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]] ]
-or-
LOCAL [ARRAY] ArrayName1(nRows1 [, nColumns1]) [AS type [OF ClassLib]]
    [, ArrayName2(nRows2 [, nColumns2]) [AS type [OF ClassLib]] ]

Parameters

  • VarList
    Specifies one or more local variables to create.
  • [ARRAY] ArrayName1 (nRows1 [, nColumns1])   [, ArrayName2 (nRows2 [, nColumns2])] ...
    Specifies one or more local arrays to create. See DIMENSION for a description of each argument.
  • AS type
    Specifies the data type on which this variable or array is based.
  • OF ClassLib
    Specifies the class library containing the type description on which the type element of this variable or array is based.

Remarks

Items within VarList are separated by commas. Local variables and variable arrays can be used and modified only within the procedure or function in which they are created, and cannot be accessed by higher- or lower-level programs. Local variables and arrays are released once the procedure or function containing the local variables and arrays completes execution.

Variables and arrays created with LOCAL are initialized to false (.F.). Any variable or array you wish to declare as local must be declared local prior to assigning it a value. Visual FoxPro generates an error message if you assign a value to a variable or array and later declare it local with LOCAL.

Local variables can be passed by reference.

You cannot abbreviate LOCAL because LOCAL and LOCATE have the same first four letters.

The strong typing required by the CodeSense parser in IntelliSense is available only when you create strongly typed object and variable references by using the optional AS clause.

When you specify a valid classname, Visual FoxPro uses the typelib (if you specify a ProgID) or instantiates the object to get the list of Properties, methods, and events. If the specified classname is not found, Visual FoxPro displays a dropdown list of available classes.

See Also

DIMENSION | FUNCTION | LPARAMETERS | PARAMETERS | PARAMETERS( ) | PRIVATE | PUBLIC | RELEASE