Code example for saving and loading text data?
BlitzMax Forums/BlitzMax Beginners Area/Code example for saving and loading text data?
| ||
Anyone got an example of how to open, close and write to text files like in Blitz3D? |
| ||
'write a file Global some_line:String[100] Local i:Int For i=0 Until some_line.length some_line[i]=String(MilliSecs()) Next Local file_out:TStream=WriteFile("file_test.data") For i=0 Until some_line.length WriteLine file_out,some_line[i] Next CloseFile file_out 're-open the same file to read it Local file_in:TStream=ReadFile("file_test.data") While Not Eof(file_in) Print ReadLine(file_in) Wend CloseFile file_in |
| ||
You can use LoadText/SaveText as well:Local s:String = "Hello World!" SaveText s, "hello.txt" s = LoadText( "hello.txt") Print s |
| ||
What does the MilliSecs() do? |
| ||
Just return the # of milli seconds from midnight (or computer bootup?) He just used it as a random example to stuff some data in a variable. It's not necessary for 'normal' use. |