First command when using custom types

Blitz3D Forums/Blitz3D Beginners Area/First command when using custom types

Wrath_of_Zeus(Posted 2003) [#1]
I am having some trouble. I would like different objects of the same type. This is not what I am trying to do, but it illistrates what I think I am seeing:

Type Aliens
Field Number
End Type

Green.Aliens = New Aliens
Green\Number = 1
Green.Aliens = New Aliens
Green\Number = 2

Gray.Aliens = New Aliens
Gray\Number = 5
Gray.Aliens = New Aliens
Gray\Number = 6

Gray.Aliens = First Aliens
Print Gray\Number

The output will be 1, instead of what I want, which is 5.

Is there a way to get what I want, which is to be able to iterate through the Gray Aliens, but not the Green?


GitTech(Posted 2003) [#2]
Something like this?

Const GREEN_ALIEN=1
Const GRAY_ALIEN=2

Type Aliens 
	Field Number 
	Field alienType
End Type 

Green.Aliens = New Aliens 
Green\Number = 1 
Green\alienType=GREEN_ALIEN
Green.Aliens = New Aliens 
Green\Number = 2 
Green\alienType=GREEN_ALIEN

Gray.Aliens = New Aliens 
Gray\Number = 5 
Gray\alienType=GRAY_ALIEN
Gray.Aliens = New Aliens 
Gray\Number = 6 
Gray\alienType=GRAY_ALIEN



For gray.Aliens=Each Aliens
	If gray\alienType=GRAY_ALIEN Then Print Gray\Number:exit
Next



soja(Posted 2003) [#3]
Yes, there is no inherent mechanism in Blitz for doing that (besides using a GreenAlien type and a GrayAlien type).

As I understand it, BlitzMax will have polymorphism, so you WOULD be able to do this. You would have an Alien base type, which your GreenAlien and GrayAlien types would inherit from. (And both would still be, technically, Alien types.)

As an alternative to checking a flag on each, you could create and/or insert them in such an order that you know which ones are gray and which are green, and you could keep pointers to them. I.e.

First-> Green
Green
Green
change->Gray
Gray
Last-> Gray

You just have to come up with some sort of mechanism that works for you. It just that anytime you use New with a custom type, the new object gets put in the linked list that corresponds to that type. (There is only one linked list of objects for each custom type.)


Wrath_of_Zeus(Posted 2003) [#4]
Thanks guys.

What is blitz max? I assume it will cost more.


soja(Posted 2003) [#5]
It's the next product in the Blitz line. Granted, there are more rumours than official facts, but if you take a composite of all the tidbits from Mark Sibly's forum posts and worklogs, and apply a healthy dose of assumption and deduction, what you end up with is basically that it's the successor of BlitzPlus and Blitz3D (together).

In fact, you could say that all the new features that get implemented in BlitzPlus will be very similar to things that are planned for BlitzMax. (Of course BlitzMax will have 3D OpenGL, will compile executables for Linux & Mac also, etc etc.)

It will most likely cost more (if you choose to buy it). It most likely will be a separate product. I'm confident it will be well worth it.


Wrath_of_Zeus(Posted 2003) [#6]
Cool