Types, DIM and deleting

Blitz3D Forums/Blitz3D Beginners Area/Types, DIM and deleting

OK, hypothetical situation to illustrate my problem.

In this example I want 20 galaxies. Each galaxy has 100 aliens. Each alien has an X value.

All galaxies must be kept separate and I also need to carefully manage memory use so I don’t start with all the galaxies and aliens defined. Instead I start with just two and add more later. I also need to delete whole galaxies.

To do this I do the following.

Type alien
Field x
End Type

Dim galaxy.alien(20)

For f=1 To 100

	galaxy.alien(1) = New alien
	galaxy(1)\x = Rnd(0,100) 

	galaxy.alien(2) = New alien
	galaxy(2)\x = Rnd(0,100) 

Next

For galaxy.alien(1) = Each alien
	Delete galaxy.alien(1)
Next

For galaxy.alien(2) = Each alien

	DebugLog  galaxy(2)\x
	
Next

Delay 1000


In deleting galaxy.alien(1) I seem to also be deleting galaxy.alien(2).

Anyone see what I’m doing wrong? I only want to delete (1). Thanks a lot.