xHarbour Reference Documentation > Function Reference |
Deletes an element from an array.
ADel( <aArray>, <nElement>, [<lShrink>] ) --> aArray
The return value is a reference to <aArray>.
The array function ADel() deletes the element at position <nElement> from the array <aArray>. All subsequent elements are shifted up by one position so that the last element contains the value NIL when the function returns. This default behaviour leaves the number of elements in the array unchanged.
If the third parameter <lShrink> is specified as .T. (true), the last element is removed from the array and the number of elements is reduced by 1.
See also: | AAdd(), ACopy(), AFill(), AIns(), ASize() |
Category: | Array functions |
Source: | vm/arrayshb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// This example demonstrates two results of deleting an // array element PROCEDURE Main() LOCAL aArray := { "A", "B", "C" } ADel( aArray, 2 ) ? Len( aArray ) // result: 3 ? aArray[1], aArray[2], aArray[3] // result: A C NIL ADel( aArray, 2, .T. ) ? Len( aArray ) // result: 2 ? aArray[1], aArray[2] // result: A NIL RETURN
http://www.xHarbour.com