FutureBasic Logo

<<    Index    >> FutureBasic

DynamicRemoveItems   statement



Syntax
DynamicRemoveItems ( dynamic(gMyDynamicArray), first, howMany, savePtr )

Description
This function deletes howMany items from gMyDynamicArray, beginning with item first. Any subsequent items will shift down to replace the removed items, resulting in an array of howMany fewer items. Each subsequent item will have its index reduced by howMany. If savePtr is 0, the data will be expunged without warning or recourse. If a pointer is passed in savePtr, the data to be removed will first be copied to that address.

Note
Whether currently populated or not, a dynamic array must have held data at some point before being passed to this function.

gMyDynamicArray is any FutureBasic Dynamic Array previously dimensioned using dynamic or dim dynamic.

first is the array position of the first item to be removed. It must be >= 0. def DynamicRemoveItems will not remove more items than exist in the array. For example, if your array holds 10 items (0-9) and you attempt to remove 5 items beginning with item 8, 2 items (8-9) will be removed instead and the array will be left with 8 items (0-7).

howMany specifies the number of contiguous items to be removed. If there are too few items following first, only the number available will be removed. savePtr is an address to which the items being removed from gMyDynamicArray will be copied.

savePtr must point to an allocated memory block (or variable) of adequate size to hold all data being removed. DynamicRemoveItems does not check to ensure there is adequate space. If there are fewer than howMany items available to remove, only the number removed will be copied to savePtr&. To remove data without saving it, pass 0 in savePtr.

See also
DynamicInsertItems; dynamic