Dynamic arrays

Giganews Newsgroups
Subject: Dynamic arrays
Posted by:  JamesR (wizzer…@hotmail.com)
Date: 30 Jul 2006

I need to add numbers to a list, but I don't know how many numbers will
be added. I know the maximum size of the list. For example, the max
could be 700, but perhaps only 200 of these numbers are added to the
list, if i'm making sense.

I was thinking I could SetLength() a dynamic array of 700, but what
then, happens if only the first 200 indexes receive something. - then
if I want to loop through the array and work with all the indexes, it
will still loop through 700 right. Is there a way to trim the unused
index? or am I approaching this all wrong?

I know I could do another setlength() for each time an index is added,
but doing that 200 times in a loop would seem awfully wasteful.

Thanks, James.