Type After and Before equivalents
BlitzMax Forums/BlitzMax Beginners Area/Type After and Before equivalents
| ||
in using TLists is there an equivalent to the old Before and After commands? I was thinking I could get the index and then get the index after or before it but I'm not seeing it. IE... I have a TList of Brushes and a global SelectedBrush if I want to nav to the next brush in the list based on the SelectedBrush, how do I do that? |
| ||
This should get you off the starting blocks. The example is using "String-based" types: |
| ||
Ohhhhhhh! Got it thanks! |
| ||
If SelectedBrush SelectedBrushL=Brushes.FindLink(SelectedBrush) SelectedBrushL=SelectedBrushL.PrevLink() If SelectedBrushL SelectedBrush=Brush(SelectedBrushL.Value()) Else SelectedBrush=Brushes.First() End If Else SelectedBrush=Brushes.Last() End If SelectedBrush:Brush Brushes:TList SelectedBrushL:Tlink In the code above I am trying to cast the found link value (which says its an object) into a brush but its saying "Unable to convert from Object() to 'unknown'" I've used casting previously so I think I'm doing that correctly... first time using Tlinks??? {edit} I added ()'s to value and now its saying cannot convert from Object() to Brush... |
| ||
This isn't a bug is it? I've searched out tutorials & documentation on this which are few relating to tlink's, but it looks like casting the returned object should work... am i missing something? |
| ||
Nope, you need to cast all of the SelectedBursh variables to Brush, not just the one... This one: SelectedBrush=Brushes.First() And this one, too: SelectedBrush=Brushes.Last() Should be: SelectedBrush=Brush(Brushes.First()) etc... |
| ||
Of course... need more sleep. TLists are object oriented.. letting my own naming convention get the better of me LOL. I didn't even notice the error was below where I had casted the value ;) Thanks.. I think thats got it now |
| ||
http://blitzmax.com/Community/posts.php?topic=50285 |
| ||
Thanks Beaker That kind of stuff really needs to be incorporated into the documentation... seriously. Rather than being buried in the forums that are for the most part difficult to search for. Anyway.. I'm sure thats just restating what has already been said quite a few times. ;) |