List Object Problem
BlitzMax Forums/BlitzMax Beginners Area/List Object Problem
| ||
Hi I want to assign a type object to the previous object in the list. In Blitz3D this would have been.. alien = Before alien I imported this BB code into Max and it told me to use... alien = alien.Before() But when I then compile it it says Identifier 'Before' not found. What am I doing wrong and how do I solve this. Thanks |
| ||
Types don't automatically create a list in Bmx. You have to create your own and then you could use method InsertBeforeLink. |
| ||
Type TAlien Global AlienList : TList 'global list to hold the aliens Field X:Int Field Y:Int Function Create:TAlien(Xval: Int, YVal: Int) Local tempAlien:TAlien = New TAlien If Not AlienList Then AlienList:TList = New TList 'create list if it does not exist tempAlien.X = XVal tempAlien.Y = YVal AlienList.AddLast(tempAlien) Return tempAlien End Function End Type Local a:TAlien For Local b:Int = 0 To 10 a:TAlien = TAlien.Create(b,b) Next For Local tempAlien:TAlien = EachIn TAlien.AlienList Print tempAlien.X + ", " + tempAlien.Y Next You can then use the TList functions on TAlien.AlienList |
| ||
I have my list already. So I would assume it would be something like..Link = MyList.FindLink(alien) Link.InsertBeforeLink(alien,MyList.LastLink)Still says Identifier 'InsertBeforeLink' not found when I try to compile it. Whats going wrong here? |
| ||
try:MyList.InsertBeforeLink(Alien, MyList.LastLink) |
| ||
my_link:TLink = mylist.findlink(mmmmm) mylist.insertbeforelink(nnnnn,my_link) I can't be sure of these as I struggle with these methods. Somebody made a good example post somewhere so search on InsertBeforeLink. |
| ||
Compile error says "Unable to convert from 'TLink()' to 'TLink'. ??? |
| ||
TLink() is a function that returns a TLink, TLink is a type Can you post a little more code? It would make it easier to debug. |
| ||
Does this help... here |
| ||
Heres the code. Actually it is working its just in an infinite loop now I think.... |
| ||
It doesn't look like you're changing the win value at any point, so this would continue ad infinitum.win:Window = Window(WindowList.Last) While win <> Null ' Update / draw window TmpLink:TLink = WindowList.LastLink() WindowList.InsertBeforeLink(win,TmpLink) Wend |
| ||
All that I want is the BlitzMax equivalent of this Blitz3D code...win.Window = Last Window While win <> Null win = Before win Wend |
| ||
Are the two any different? |
| ||
Ok I have worked around the problem now with the following code. Its not ideal but It does the same thing. Thanks for all of your help. |