For each custom type

BlitzMax Forums/BlitzMax Beginners Area/For each custom type

Czar Flavius(Posted 2007) [#1]
In earlier versions of Blitz Basic I could write:

For a.atype = Each atype

But now I cannot do this. I have to do something with collections and adding methods such as ObjectEnumerator but, as usual, the documentation is about as useful as a chocolate kettle. Please help.


GfK(Posted 2007) [#2]
Global aTypeList:tList = New tList

For N = 1 to 10
  a:aType = new aType
  a.x = rand(0,50)
  a.y = rand(0,20)
  aTypeList.AddLast(a)
Next

For a:aType = EachIn aTypeList
  Print a.x
  Print a.y
Next

Type aType
  Field x:int
  Field y:int
End Type



Czar Flavius(Posted 2007) [#3]
Thanks.

During searching I found this:
http://www.blitzbasic.com/Community/posts.php?topic=59233

Even though I've found a solution, I am still curious about what the way we're "supposed" to do it is, with ObjectEnumerator...


Who was John Galt?(Posted 2007) [#4]
That's all Blitz internals that you don't need to worry about. Gfk's way is the way we are 'supposed' to do it.


H&K(Posted 2007) [#5]
Yep, this is explained in
Orientation guide for existing Blitz users http://www.blitzbasic.com/Community/posts.php?topic=41179

The problem with the original method was that there was one list that had all of that type in it. Now... well etc


Brucey(Posted 2007) [#6]
The ObjectEnumerator stuff is great if you want to create your own Types that support the "Eachin" feature.

Not that its use is documented very well, mind you... case of trial and error (and looking at the Blitz code) to get it right.


Czar Flavius(Posted 2011) [#7]
I miss the good old days.