ID: Q89663
The information in this article applies to:
The DECLARE command has the same function and syntax as the DIMENSION command. The text below describes how to use these commands to specify a default value for an array.
DECLARE <ARRAYNAME>[<NUMBER OF ELEMENTS>] DECLARE <ARRAYNAME>(<NUMBER OF ELEMENTS>)
DECLARE NAME[10]
This example declares a one-dimensional array that contains ten
elements.
DECLARE NAME(10,2)
This example declares a two-dimensional array that contains two
columns of ten elements each.
DIMENSION <ARRAYNAME>[<NUMBER OF ELEMENTS>] DIMENSION <ARRAYNAME>(<NUMBER OF ELEMENTS>)
DIMENSION NAME(10)
This example declares a one-dimensional array that contains ten
elements.
DIMENSION NAME[10,2]
This example declares a two-dimensional array that contains two
columns of ten elements each.
The DECLARE and DIMENSION commands can create one-dimensional and two-dimensional arrays of memory variables.
Each array uses one memory variable for overhead and is limited to a maximum of 3600 elements in the Standard version of FoxPro and 65,000 elements in the Extended version of FoxPro. Sufficient memory to allocate space to store the array is required.
The elements of a memory variable array can contain any data type. Each array element is initialized to the logical value .F. when it is first declared or dimensioned.
The DECLARE AND DIMENSION commands support both square brackets and parentheses to delimit the number of elements. An array that is created in the Command window is automatically declared PUBLIC, while an array created in a program is declared PRIVATE by default. An application can use the PUBLIC command to make an array public.
The two techniques demonstrated in the following examples can be used with two-dimensional arrays as well as one-dimensional arrays:
STORE "TEST" to NAME
This example initializes each element of the NAME array to the value "TEST."
STORE "TEST" TO NAME(1)
This example initializes only the first element of the NAME array to "TEST."
NAME="TEST"
This example initializes each element of the NAME array to the value "TEST."
NAME(1)="TEST"
This example initializes only the first element of the NAME array to "TEST."
NAME=.F.
Additional reference words: FoxDos FoxWin 2.00 clearing setting 2.50 2.50a
KBCategory: kbenv kbprg
KBSubcategory: FxenvMemory
Last Reviewed: June 27, 1995