Type After and Before equivalents

BlitzMax Forums/BlitzMax Beginners Area/Type After and Before equivalents

_Skully(Posted 2009) [#1]
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?


EOF(Posted 2009) [#2]
This should get you off the starting blocks. The example is using "String-based" types:




_Skully(Posted 2009) [#3]
Ohhhhhhh! Got it thanks!


_Skully(Posted 2009) [#4]
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...


_Skully(Posted 2009) [#5]
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?


TaskMaster(Posted 2009) [#6]
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...


_Skully(Posted 2009) [#7]
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


Beaker(Posted 2009) [#8]
http://blitzmax.com/Community/posts.php?topic=50285


_Skully(Posted 2009) [#9]
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. ;)