'Clearing' an array

BlitzMax Forums/BlitzMax Beginners Area/'Clearing' an array

Ant(Posted 2006) [#1]
Hi, I use an array of ints to track a list of numbers that I want to store. I add a series of numbers to this array and then when I have processed what I need to process I set all the elements in the array to NULL ( I essentailly just want to clear the list as I use the array.length method to determine how many elements I have in the array).
However, when the code loops around and I again want to store a number in the array, it complains as the array is NULL and moans"Attempt to index array element beyond array length". So the question is how do I 'clear' the array (I dont want to put an arbitary number in there as I need to use the length method). Should I just reinitialise the array every time it needs it? Seems a bit sloppy!
Thanks


Chris C(Posted 2006) [#2]
you might want to consider using lists, they are very powerful...


Ant(Posted 2006) [#3]
I do almost exlusively - the reason that I'm not here is that I only want to store some integers - and I thought lists could only work with objects, not simple integers?


Ant(Posted 2006) [#4]
I just reinitialsed the array and it seems to work
cheers


ImaginaryHuman(Posted 2006) [#5]
Reinitializing it means trashing the old array, allocating memory space for the new one and recreating it. That might be slow.

Can't you just cycle through the array and set each value to 0?