[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|            DIMENSION            |
+---------------------------------+
DIMENSION <array1> (<expN1>
        [, <expN2>])
        [, <array2> (<expN3>
        [, <expN4>])] ...

-----------------------------------
Creates array of memory variables.
-----------------------------------

One or two-dimensional arrays of memory variables can be created with
the DIMENSION statement.  The DIMENSION command is identical in
operation and syntax to the DECLARE command.

Each array uses one memory variable and is limited to a maximum of 3,600
elements.  You must have sufficient memory available to allocate space
for an array.

The elements of a memory variable array may contain any type of data.
Array elements are initialized to a logical value of false (.F.) when
they are first dimensioned or declardd.  An entire memory variable array
may be initialized by using the STORE command if you SET COMPATIBLE to
FOXPLUS or to OFF.

Square brackets and parentheses are both supported when defining arrays
with the DIMENSION or DECLARE commands.  Arrays that are created in the
Command window are automatically made PUBLIC while arrays created from
within a program are made PRIVATE.  An array can be created and made
public within a program by using the PUBLIC command.

Subscripts in a memory variable array start with 1.  If an array is
DIMENSIONed with two subscripts (a two-dimensional array), it can also
be accessed with a single subscript.  To determine which single
subscript corresponds to a pair of subscripts, note that the elements
are stored in row-significant order.  The AELEMENT() function returns
the proper single subscript from a pair of array row and column
subscripts.  Conversely, the ASUBSCRIPT() function returns the row and
column subscripts from a single subscript.

Redimensioning arrays
---------------------

You may change the size and dimensions of an array by using the
DIMENSION command again.  The size of an array may be increased or
decreased, one-dimensional arrays may be converted to two dimensions and
two dimensional arrays reduced to one dimension.

Include the name of the array to redimension.  If the number of elements
in an array is increased, the contents of all the elements in the
original array are copied to the newly redimensioned array.  The
additional array elements are initialized to a logical false (.F.).  If
the number of elements in an array is decreased, the additional elements
are truncated.

If a one-dimensional array is redimensioned to two dimensions, the
contents of the original one-dimensional array are copied to the new
array in an element to row order.  When a two-dimensional array is
converted to one dimension, the contents of the original two-dimensional
array are copied to the new array in a row to element order.  The first
element in the first row becomes the first element in the
one-dimensional array, the second element in the first row becomes the
second element and so on.

Elements, rows and columns may be deleted from or inserted into one and
two-dimensional arrays with the ADEL() and AINS() functions.

The APPEND FROM ARRAY, COPY TO ARRAY, SCATTER and GATHER commands allow
you to easily transfer data between database records and arrays.

Clauses
-------

<array1>
        Name of array to create.

<expN1> [, <expN2>]
        Specifies dimensions and size of array.

+---------------------------------+
|         Program Example         |
+---------------------------------+
In this example, two-dimensional array is created and loaded with data.
Array elements and data they contain are then displayed on screen.

DIMENSION sample(2,3)
STORE 'Goodbye' TO sample(1,2)
STORE 'Hello' TO sample(2,2)
STORE 99 TO sample(6)
STORE .T. TO sample(1)
DISPLAY MEMORY LIKE sample

-----------------------------------

See Also:  ADEL(), AELEMENT(), AINS(), APPEND FROM ARRAY, ASUBSCRIPT(),
COPY TO ARRAY, DECLARE, GATHER, PUBLIC, PRIVATE, SET COMPATIBLE,
SCATTER, STORE

-----------------------------------

See Also: ADEL() AELEMENT() AINS() APPEND FROM ARRAY ASUBSCRIPT()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson