FutureBasic Logo

<<    Index    >> FutureBasic 5

DynamicRemoveItems   statement

DynamicRemoveItems ( Dynamic( gMyDynamicArray ), First&, HowMany&, SavePtr& )

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.

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