Finding Specific item in a list..

BlitzMax Forums/BlitzMax Beginners Area/Finding Specific item in a 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.

Hello ppl,

As always, when I need to do something in my program, I test it seperately with my own small code. Now I need to pull a specific item from a list, and display it. This easy-to-read code, should explain what I want to do:

SuperStrict
Global Counter:Int
Global CarList:TList=CreateList()

ListAddLast CarList,"Volvo"
ListAddLast CarList,"Blue"
ListAddLast CarList,"$10.000"

ListAddLast CarList,"Chevrolet"
ListAddLast CarList,"Red"
ListAddLast CarList,"$80.000"

ListAddLast CarList,"Ferrari"
ListAddLast CarList,"Red"
ListAddLast CarList,"$200.000"

Print "The Chevrolet costs:"

For Local a:String=EachIn CarList
	If a="Chevrolet" Then Counter = 1
	If Counter = 3 Then Print a ; End
	If Counter < 3 Then Counter:+1
Next


Is there a quicker way, to pull the price of the Chevrolet car? I go through the whole list, until I find it. Isn't there a way to go directly to it? I have been playing around with "ListFindLink", but can't get it to work with a String..?