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.
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
Thanks.
During searching I found this:
http://www.blitzbasic.com/Community/posts.php?topic=59233Even though I've found a solution, I am still curious about what the way we're "supposed" to do it is, with ObjectEnumerator...
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.
Yep, this is explained in
Orientation guide for existing Blitz users
http://www.blitzbasic.com/Community/posts.php?topic=41179The problem with the original method was that there was one list that had all of that type in it. Now... well etc
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.