Why you should name types?

Blitz3D Forums/Blitz3D Beginners Area/Why you should name types?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This isn't true, I think.

When you do this:

For temp = 1 To 5 
	cats.sprite = New sprite 
	cats\LOCX = Rand(100) 
	cats\LOCY = Rand(200) 
	cats\CURRENTFRAME= Rand(1,8)-1 
	cats\MAXFRAME= 8 
Next 


Doesn't this loop create 5 instances, each one with the name "cats" and of type "sprite"?

So you actually have 5 different type instances,
all called "cats.sprite".

Or am I wrong?

And the name doesn't matter.

Create this program:

; Initialize window
Graphics 640, 480, 0, 2

; Create a type, called "sprite" and assign some fields to it
Type SPRITE 
	Field LOCX 
	Field LOCY 
	Field CURRENTFRAME 
	Field MAXFRAME 
End Type 

; Create 5 instances of the "sprite"-type, each one called "cats", and give the fields some values
For temp = 1 To 5 
	cats.sprite = New sprite 
	cats\LOCX = Rand(100) 
	cats\LOCY = Rand(200) 
	cats\CURRENTFRAME= Rand(1,8)-1 
	cats\MAXFRAME= 8 
Next 

For SomeRandomName.sprite= Each sprite 
	Print SomeRandomName\LOCY
Next 

While Not KeyHit(1)
Wend

End


You will see that, when printing the fields, there's no instance created anywhere in the program called "SomeRandomName".

It just prints the field LOCY of any types of type "sprite",
not just the ones that have the name "SomeRandomName".
If the names of the type-instances were important,
then Blitz3D would complain that there were no instances created in the program with the name "SomeRandomName",
or if it didn't give an error, it would just print nothing.