Okay, that makes sense.
How about this? Why doesn't this work? As you can see, I really want a scaling list data type.
Code:new list as List
for i = 1 to 100
print "adding item: "; i
call list::add i
next i
class List
dim temp(1)
dim storage(10)
dim expandBy
dim size
dim amount
sub List
expandBy = 10
size = 0
amount = 10
end sub
sub add item
size = size + 1
if size > amount then
amount = amount + expandBy
call this::expand amount
end if
storage(size) = item
end sub
private sub expand newSize
redim temp(size)
for i = 0 to size
temp(i) = storage(i)
next i
redim storage(newSize)
for i = 0 to size
storage(i) = temp(i)
next i
redim temp(1)
end sub
end class
Edit:
Even with try/catch it isn't catching it! (swap the sub in below)
Code: private sub expand newSize
try
redim temp(size)
for i = 0 to size
temp(i) = storage(i)
next i
redim storage(newSize)
for i = 0 to size
storage(i) = temp(i)
next i
redim temp(1)
catch
print err$
end try
end sub