Deletes an element from a one-dimensional array, or deletes a row or column of elements from a two-dimensional array. Returns 1 if successful; generates an error if unsuccessful. The remaining elements move forward to replace the deleted element(s); the dimensions of the array do not change.

Syntax

<oRef>.delete(<position expN> [, <row/column expN>])

<oRef>

A reference to the one- or two-dimensional array from which you want to delete data.

<position expN>

When the array is a one-dimensional array, <position expN> specifies the number of the element to delete.

When the array is a two-dimensional array, <position expN> specifies the number of the row or column whose elements you want to delete. The second argument (discussed in the next paragraph) specifies whether <position expN> is a row or a column.

<row/column expN>

Either 1 or 2. If you omit this argument or specify 1, a row is deleted from a two-dimensional array. If you specify 2, a column is deleted. dBASE Plus generates an error if you use <row/column expN> with a one-dimensional array.

Property of

Array

Description

Use delete( ) to delete selected elements from an array without changing the size of the array. delete( ) does the following:

Deletes an element from a one-dimensional array, or deletes a row or column from a two-dimensional array

Moves all remaining elements toward the beginning of the array (up if a row is deleted, to the left if an element or column is deleted)

Inserts false values in the last position(s)

Adjust the array’s size property or use resize( ) to make the array smaller after you delete( ) if you want the net effect of removing elements.

One-dimensional arrays

When you issue delete( ) for a one-dimensional array, the element in the specified position is deleted, and the remaining elements move one position toward the beginning of the array. The logical value false is stored to the element in the last position.

For example, if you define a one-dimensional array with

aAlpha = {"A", "B", "C"}

the resulting array has one row and can be illustrated as follows:

A B C

Issuing aAlpha.delete(2) deletes element number 2 whose value is "B," moves the value in aAlpha[3] to aAlpha[2], and stores false to aAlpha[3] so that the array now contains these values:

A C false

Two-dimensional arrays

When you issue delete( ) for a two-dimensional array, the elements in the specified row or column are deleted, and the elements in the remaining rows or columns move one position toward the beginning of the array. The logical value false is stored to the elements in the last row or column.

For example, suppose you define a two-dimensional array and store letters to the array. The following illustration shows how the array is changed by aAlpha.delete(2,2).

image\AALPHA1_shg.gif