How to access a specified TList Item?

BlitzMax Forums/BlitzMax Beginners Area/How to access a specified TList Item?

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.

hi andre72,

i can't really figure out what you are trying to do (sorry) but to try to answer your question : "How to access a specified TList Item?"

i usually go like the following though i think there exist a better way of doing it:
SuperStrict 
Global t:test
Global list:TList=New TList
Type test
	Field str$ 
	Field ID%
	
	Function create:test(n%,name$)
		 
		t:test=New test
			t.str = name 
			t.ID = n
			ListAddLast list, t
			Return t
	EndFunction 
	
	Method print_1()
		If ID = 4 
			Print str
		EndIf  
	EndMethod 
	
EndType

	
For Local m%=0 To 6
		Local data$
		ReadData data
		test.create(m%, data)
Next 

For t:test=EachIn list
		t.Print_1()
Next


#mydata

DefData "Steve"		'ID 0
DefData "JB"		'ID 1
DefData "Mike"		'ID 2
DefData "Fil"		'ID 3
DefData "andre72"	'ID 4
DefData "fab"		'ID 5
DefData "jim"		'ID 6