Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete an element from a dynamic array

Status
Not open for further replies.

hayate

Programmer
May 17, 2003
7
JP
Hi, there.

I want to delete an element from a dynamic array.
I read Delphi's help and it tells that I can use Delete to delete an element from an array.So I used Delete but it doesn't work. An error occurs.

Thanks in advance.
 
Can you show us the code and the error message? Does this error occur at compile time or at run time?

Andrew
 
I dont often use dynamic array, i dont know if it's the best way but it's working fine..

1) (if order does'nt matter)
Swap last item and the item you whant to remove.

(if order matter)
Swap item u whant to remove with the next item till the
item to remove is'nt at the end.

2) decrement the size of the array by one (set new size at size -1)


jb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top