how to use insertafterlink?

BlitzMax Forums/BlitzMax Beginners Area/how to use insertafterlink?

if you are adding an object after cursor in a list it will bomb if cursor has not alread been added to that list

maybe you added cursor to a different list?

the debugger is nearly there which should help you out a lot getting to grips with things but you hopefully can work out from the error message which object is null

here is a version with a little more error checking:

Function InsertAfter(list:TList,a:Object,b:Object)
	Local	link:TLink
	link=list.FindLink(a)
	Assert link Else "Can't find Object "+a.ToString()+" In List"
	list.InsertAfterLink(b,link)
End Function

t:TList=New TList
t.AddLast "A"
t.AddLast "B"

InsertAfter t,"D","C"

For a$=EachIn t
	Print a
Next