GetLastInList

BlitzMax Forums/BlitzMax Beginners Area/GetLastInList

WARPY from the #blitzbasic IRC responded with a great answer..
We need to add links.. and we're good to go..
mylist:TList=New TList
'(fill up list)

link:TLink=mylist.FirstLink()

While whatever
   If KeyHit(KEY_UP)
      'move to previous item
      If link.PrevLink()
         link=link.PrevLink()
      Else 'this was the first link, so wrap around to the last one in the list
         link=mylist.LastLink()
      EndIf
   ElseIf KeyHit(KEY_DOWN)   
      'move to next item
      If link.NextLink()
         link=link.NextLink()
      Else 'this is the last link, so wrap around to the first one in the list
         link=mylist.FirstLink()
      EndIf
   EndIf

'do whatever you do with the current link here

Wend