Reading Text files
BlitzMax Forums/BlitzMax Beginners Area/Reading Text files
| ||
If I save a text file in NotePad how can I read into my program.?Also How can I detect when there is a new line character code in the text file (for lists)? Appreciate any help - Thank you |
| ||
Adjusted slightly from the docs :' readfile.bmx ' the following prints the contents of this source file file:TStream=ReadFile("test.bmx") If Not file RuntimeError "could not open file openfile.bmx" While Not Eof(file) Print ReadLine(file) Wend CloseStream file |
| ||
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 |
| ||
After you get that working you really should create some kind of system for encrypting highscore data. You want people making high scores with your game instead of Notepad. ;) |
| ||
OK - Thanks guys! - that worked great I thought that maybe it was in a special file format or something and I was looking in the wrong place in the docs. Thanks again! :) |