Declare an array
DIMENSION <array>[<expN>] | (<expN>)
DIMENSION <array>[<expN1>,<expN2>] | (<expN1>,<expN2>)
DIMENSION <array> | ()
AAVERAGE(), ACOPY(), ADEL(), ADIR(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, ARRAY(), ASORT(), ASUM(), COPY TO ARRAY, DECLARE, GATHER, GETMEMBER(), IN_ARRAY(), IS_ARRAY(), LOCAL, PRIVATE, PUBLIC, RELEASE, RESTORE, SAVE, SCATTER, VARINFO()
The DIMENSION command is synonymous with the DECLARE command and is used to declare memory variables, fixed one or two-dimensional arrays and dynamic arrays. Memory variables declared using the DIMENSION command are initialized to .F. and are private to the declaring procedure.
For fixed arrays, the array size is set at its declaration. Dynamic arrays are declared without a size. Array subscripts can be referenced using square brackets or round brackets.
[<expN>] | (<expN>)
For one-dimensional arrays, [<expN>] specifies the total number of elements in the array. Elements are subsequently referenced using the notation <array>[<expN>] or <array>(<expN>).
[<expN1>,<expN2>] | (<expN1>,<expN2>)
For two-dimensional arrays, <expN1> represents the number of rows and <expN2> represents the number of columns in the array. Elements are subsequently referenced by <array>[<expN1>,<expN2>] or <array>(<expN1>,<expN2>). The elements of a two dimensional array can also be referenced, as if the array were one dimensional, using <array>[<expN1>] or <array>(<expN>).
Fixed arrays can be declared as any size. Values are assigned into arrays using the '=' operator. Arrays can then be used in a similar way to memory variables. Complete arrays can be initialized with one assignment. Array references start at 1,1 for two-dimensional arrays, and 1 for one-dimensional arrays.
 | ()
Dynamic arrays are declared without specifying a size. Elements are added using arrayname.element syntax.
aDynarray.name = [Lianja Inc] aDynarray.email = [email@example.com]
They can then be referenced by element number or by element name.
? aDynarray.name Lianja Inc ? aDynarray firstname.lastname@example.org
Notes: The brackets shown for this command do not indicate optional expressions but are a necessary part of the syntax. Arrays can also be declared using any of the scoping commands: LOCAL, PRIVATE and PUBLIC.
// Declare one-dimensional array of 4000 elements dimension aTable // Assign 0 to all elements aTable = 0 // Insert individual element values into array aTable = 10 aTable = "Hello" aTable = "World" aTable = date() // Print value of element 2 ? aTable Hello // Another example dimension twodim[3,3] twodim[2,3] = "hello world" ? twodim hello world // Another example use payroll dimension aPayroll[reccount(), fcount()] copy to array aPayroll for city = "LONDON" // Dynamic array dimension aDynarray aDynarray.name = [Lianja Inc] ? aDynarray.name Lianja Inc ? aDynarray Lianja Inc