type while/wend loop

BlitzMax Forums/BlitzMax Beginners Area/type while/wend loop

Bremer(Posted 2005) [#1]
I think its been asked before, seem to remember seeing it, but can't find it, so I am just going to ask:

With B+ and B3D, you can go through a type list in reverse by doing something like this:

type testtype
end type

test.testtype = last testtype
while test <> null

test = before test
wend


How would you go about doing the same with Bmax ?


Yan(Posted 2005) [#2]
This seems to work...



Bremer(Posted 2005) [#3]
For some reason I can't get the above to work, is there a way to do the following in reverse order?

Global GUI_WINDOW_LIST:TList = CreateList()
Type GUI_WINDOW
End Type

For Local wgui:GUI_WINDOW = EachIn GUI_WINDOW_LIST
Next



Perturbatio(Posted 2005) [#4]
Global GUIWinList:TList = CreateList()
Type TGUIWin
	Field val:Int
End Type

For Local t:Int =0 To 10
	Local tempwin:TGUIWin = New TGUIWin
		tempwin.val = t
		GUIWinList.AddLast(tempWin)
	tempwin = Null
	FlushMem
Next

Local Link:TLink = GUIWinList.LastLink()
While Link
	Print TGUIWin(Link.Value()).val
	
	Link = Link.PrevLink()
Wend


You can't use Eachin without implementing your own enumerator.


Bremer(Posted 2005) [#5]
I didn't get how the value() thing worked, but looking at your code examples I got it working now and figured out what it does. so thanks guys, the help is appreaciated.