Defines one or more fixed arrays.

Syntax

DECLARE <array name 1>"["<expN list 1>"]"
[,<array name 2>"["<expN list 2>"]" ...]

Brackets ([ ]) in quotation marks are required syntax components.

<array name 1>[,<array name 2> ...]

The memory variable(s) that are the name(s) of the array(s).

"["<expN list 1>"]"[,..."["<expN list 2>"]"][,...]

Numeric expressions (from 1 to 254 inclusive). The number of expressions you specify determines the number of dimensions of the array. Each one of the expressions specifies how many values (data elements) that dimension has. For example, if [<expN list 1>] is [3,4], dBASE Plus defines a two-dimensional array with three rows and four columns.

Description

Use DECLARE to define an array of a specified size as a memory variable. Array elements can be of any data type. (An array element can also specify the name of another array.) A single array can contain multiple data types. When you use DECLARE, all array elements are initialized to a logical data type with a value of .F.

The array can hold as many elements as memory allows. You can create arrays that contain more than two dimensions, but most dBL array functions work only on one- or two-dimensional arrays.

There are two ways to refer to individual elements in an array; you can use either the element subscripts or the element number. Element subscripts indicate the row and column in which an element is located. Element numbers indicate the sequential position of the element in the array, starting at the first row and first column of the array. To determine the number of elements, rows, or columns in an array, use ALEN( ).

Certain dBL functions require the element number, and others require the subscripts. If you are using one- or two-dimensional arrays, you can use AELEMENT( ) to determine the element number if you know the subscripts, and ASUBSCRIPT( ) to determine the subscripts if you know the element number.

After you create an array, you can place values in cells of the array using STORE, or you can use =. You can also use AFILL( ) to place the same value in a range of cells in the array. To add or delete elements from an array, use ADEL( ) and AINS( ). To resize an array, or make a one-dimensional array two-dimensional, use AGROW( ) or ARESIZE( ).

You can pass array elements as parameters, and you can pass a complete array as a parameter to a program or procedure by specifying the array name without a subscript.