Reading Text files

BlitzMax Forums/BlitzMax Beginners Area/Reading Text files

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 m8. Here is some code I use to save highscores!

To save!


success=CreateFile("high.txt")
If Not success RuntimeError "error creating file"

file=WriteFile("high.txt")

If Not file RuntimeError "failed to open test.txt file" 

For i=0 To 9
	For j=0 To 1
	WriteLine file, highscores$[i,j]
	Next 
Next 

CloseStream file



To Load!
file=ReadFile("high.txt")

If Not file RuntimeError "failed to open high.txt file" 

For i=0 To 9
	For j=0 To 1
	data$=ReadLine (file)
	highscores$[i,j]=data$
	Next
Next
CloseStream file