How do I make a list?

BlitzMax Forums/BlitzMax Beginners Area/How do I make a list?

Emmett(Posted 2005) [#1]
Here is the program in a nutshell:
50 State tiles on the left of screen, 50 Capital tiles on the right of the screen.
Student picks State - Then looks for the correct Capital.

I want to keep a list of the State tiles and Capital tiles the student misses. When all States and Capitals are picked the program displays a count of how many were missed and recommends further study.

If they select Yes - all tiles are redrawn.

I want to change that so that only the States and Capitals that were missed are redrawn.

So the question is, how do I make such a list?


LarsG(Posted 2005) [#2]
perhaps you can set up a "state" type with two fields; "state" and "capital".
you should setup a list with the correct values.
The do a ERROR list of the same "state" type, which you add to when the user makes a wrong choice (by checking the correct list), and the two fields are filled with the (wrong) choice they did..

at the end, you can count the ERROR list to see how many wrongs they mad.. (and perhaps even display the values they picked)

dunno if you understand what I mean.. I'm about to go to bed, and I'm not sure if I can make any sense of it myself.. LOL


Perturbatio(Posted 2005) [#3]
surely you only need to track the state tiles since the capitals are directly linked to them?

In which case, just use a TList object and add the appropriate data in, then at the end you can simply loop through the list to display the incorrect ones.


tonyg(Posted 2005) [#4]
Yep, a single type with state, capital and status all added to a single list.
Set status to '0' or incorrect at the start and to '1' or correct when they've got it right.
Read through the list only displaying those 'incorrect' until the student wants to start again. At that point ooop through the entire list change correct to incorrect again.


Emmett(Posted 2005) [#5]
Thank you all.
After trying to set up a Tlist following some examples it looks to me like a Tlist cannot be created without a Type?

Is this even close to the answer?
Type state
   field state, capital
End Type

Global missed : state = New state

' Now in the function that reports wrong matches -

if state wrong missed.state = gotstate ' This is the state variable
if capital wrong missed.capital = got capital ' This is the capital variable

Hmm, the Tlist is missing.

The two variables - gotstate and gotcapital are Frame numbers to the LoadAnimImage states and LoadAnimImage capitals.
BTW: The States and Capitals are both arranged to be in alphabetical order so StateFrame 0 = 0 and CapitalFrame 0 = 31.

Do I add to the code:
missed:Tlist=createlist()
Then in the function for reporting wrong matches -
listaddlast missed , gotstate
listaddlast missed , gotcapital

Whew - this is getting a bit convoluted. sorry.


Perturbatio(Posted 2005) [#6]
Type TStateGlobal StateList:TList = CreateList()


Function CheckMatch(State:Int, Capital:Int)

	If wrong then ListAddLast(StateList, State) 'no need to add the capital unless you want to tell them what they chose.
				'you just need the state since there is only one capital per state.

End Function