hi all,
I've a little problem with dimdel. I got the Error:
bounds: [ 100]
access: [ 100]
Ausserhalb des DIM Bereichs (Array out of bounds).
But the Array ist not out of bounds.
GLOBAL Array[]
DIM Array[200]
FOR i = 0 TO 199
Array[i]=i
NEXT
FOR i = 0 TO 199
DIMDEL Array[],i
NEXT
After I double the Array-lengh to 400 it works.
Can someone help what I'm doing wrong?
What happens is that you are reducing the size of the array by 1 each loop, and doing it 200 times (or trying to at any rate).
However, once you get to index 100, the array size is also 100 and so trying to access index 101 would be impossible as it can't exist. Hence you get an "out of bounds error".
What you should be using is :
FOR i = 0 TO 199
DEBUG i+" "+BOUNDS(Array[],0)+"\n"
DIMDEL Array[],0
NEXT
Many thanks. Now it works.
I overlooked that dimdel reindex the Array. Now it make sense why 'dimdel array[], -1' worked
Many thanks again.
Hi
My nested loops question was similar ... and I got lot of help.
I was dimdel-ing inside the loop.
FOREACH with a DELETE
or
For n = highest to 0 step -1 (reverse array)
or wait until out of the loop and dimdel then.
Just thought u might like to see the other options...
Thanks for the help, but I only tried to make a performance-test with arrays. I looked how much CPU usage dimpush, dimdel and delete used compared to overwriting values in a static array.
I overlooked the reindexing that is used by dimdel and delete, so I got these error.