Sorry but I can not get this working...
type ball
x
y
dx
dy
endtype
global bola[] as ball
dimpush bola[],0
I always get a compiler error. So I have to use
m=bounds(bola[],0)
redim bola[m+1]
The second argument of dim push should be a variable to 'push' onto the end of the array. You're specifying a '0' when the compiler is expecting a variable of the ball type. If it's expecting a ball, it doesn't know what to do with a 0...
This is what DIMPUSH is meant for:
// Add a new ball to the list
LOCAL NewBall AS ball
NewBall.x = 10
NewBall.y = 20
NewBall.dx = 5 //assuming that 'dx' and 'dy' refer to speed as there are no 'vx' and 'vy'
NewBall.dy = 2
DIMPUSH bola[], NewBall
If you just want to use DIMPUSH to extend the array by 1, you would have to use a variable of the type 'ball' like in my short example with all blank values.
Normally if you need to extend the array you will be putting in values anyway, so it's easier to put them in something like 'NewBall' and then 'push' that onto the array, but otherwise you should just do something like what you listed. I normally do this:
REDIM bola[LEN(bola[])+1]
just because it's easier to type, and doesn't need the temporary variable.
You would only do something like :
DIMPUSH bola[],0
if bola was a simply integer or floating-point array