reading files and info in order

BlitzMax Forums/BlitzMax Programming/reading files and info in order

djdee(Posted 2006) [#1]
Just a question.
Were working on a schoolproject with BlitzMax that is due tomorrow morning. Much of our work have involved planning so that everything should work smooth. This has included making files that match the order that our content files are in alphabetically. However, when loading these contentfiles, they didnt come in alphabetical order. Also when loading in the content of a file, it seems, it doesnt come in order either, everyhting is just mixed in no particular sense at all. Heres how our code looks for reading content from a file:

countryFile = OpenStream( countryFileName, True, False )

If Not countryFile RuntimeError "Failed to read file containing list of countries."

locationList = New TList

While Not Eof( countryFile )
ListAddLast( locationList, ReadLine( countryFile ) )
Wend

this should be straightforwad and read in whatever is there. What about when you do the:

for ... eachin locationList

does it iterate in order ? if not, is there a way to make it do so ??


djdee(Posted 2006) [#2]
Also, we cant use sortlist(locationList) because, we use asterixes to tell the program where certain things begin and end...


djdee(Posted 2006) [#3]
So what im trying to say is, that, when we try tu use the info from the file, it doesnt come in the order we had in the file, if we grab it through the for...eachin method..


skidracer(Posted 2006) [#4]
Yes eachin does iterate in order. I would look for other problems with your code, make sure you are closing files, if you have multiple files open at one time make sure each is using a unique variable etc. Post your entire program here if you get completely stuck.