Share via


ADEL( ) Function

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

ADEL(ArrayName, nElementNumber [, 2])

Return Value

Numeric

Parameters

  • ArrayName
    Specifies the array from which the element, row, or column is deleted.

  • nElementNumber
    Specifies the number of the element, row, or column to delete from the array. If the array is multidimensional, nElementNumber will specify the row. You must include the optional 2 argument to delete a column from the array.

    Tip

    For more information on how to reference elements in an array, see DIMENSION Command.

  • 2
    Deletes a column from the array.

Remarks

Deleting an element or row from an array doesn't change the size of the array; instead, the trailing elements, rows, or columns are moved towards the start of the array, and the last element, row, or column in the array is set to False (.F.). If you delete a column, values of the elements in the deleted column are set to False (.F.), but trailing elements are not moved.

If the element, row, or column is successfully deleted, 1 is returned.

Example

The following example creates and fills an array, then searches for a particular company name, which, if found, is removed from the array.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer     && Open customer table
SELECT company FROM customer ;
   WHERE country = 'UK' ;
   INTO ARRAY gaCompanies
gnCount = _TALLY
gcName = 'Seven Seas Imports'
CLEAR
DISPLAY MEMORY LIKE gaCompanies
gnPos = ASCAN(gaCompanies, gcName)   && Search for company
IF gnPos != 0
   * Company found, remove it from the array
   = ADEL(gaCompanies, gnPos)
   gnCount = gnCount - 1
ENDIF
DISPLAY MEMORY LIKE gaCompanies

See Also

Reference

ACOPY( ) Function

ADIR( ) Function

AELEMENT( ) Function

AFIELDS( ) Function

AINS( ) Function

ALEN( ) Function

ASCAN( ) Function

ASORT( ) Function

ASUBSCRIPT( ) Function

DIMENSION Command

Other Resources

Functions

Language Reference (Visual FoxPro)