TList question - Moving through list

BlitzMax Forums/BlitzMax Beginners Area/TList question - Moving through list

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'd do it this way. Personal preference I suppose, I just find it simpler. This isn't checking for errors but all you'd need to do is check for null returns before trying to change Type contents:
Global stringList:TList = New TList
Local s:tString

'put some random chars in list
For N = 1 To 10
	s = New tString
	s.text = Chr$(Rand(65,97))
	stringList.addLast s
Next

'change value of item 4
s = tString(stringList.valueAtIndex(4))
s.text = "Replaced this item!"

'find next link and change value
getNext(s).text = "Replaced the next one too!"


'output
For s = EachIn stringList
	DebugLog s.text
Next

'function to get next object in list
Function getNext:tString(nLink:tString)
	nLink = tString(stringList.FindLink(nLink).NextLink().Value())
	Return nLink
End Function

'declaration
Type tString
	Field text:String
End Type