b3d after command in bmax?

BlitzMax Forums/BlitzMax Beginners Area/b3d after command in bmax?

I have written 2 Functions that should be equal to After and Before.

Here is the code:


Type TBase

Field ID:Int

End Type

For x = 1 To 6
Local T:TBase = New TBase
T.ID = X
List.Addlast(T)
Next
Global T1:Tlink = List.FirstLink()

For P:TBase = EachIn List
	P1:TBase = P
	P2:TBase = TBase(After(List,P1))
	P3:TBase = TBase(Before(List,P1))
	Print P1.ID
	Print P2.ID
	Print P3.ID
	Print "---------"
Next

Function After:Object(List:Tlist,value:Object)

	Local T1:Tlink = List.FindLink(value)
	Local T2:Tlink = T1.NextLink()
	If T2 = Null Then
		Return List.FirstLink().Value()
	Else
		Return t2.value()
	EndIf
	
End Function

Function Before:Object(List:Tlist,value:Object)

	Local T1:Tlink = List.FindLink(value)
	Local T2:Tlink = T1.PrevLink()
	If T2 = Null Then
		Return List.LastLink().Value()
	Else
		Return t2.value()
	EndIf
	
End Function


I hope that this is what you was looking for.