Code example for saving and loading text data?

BlitzMax Forums/BlitzMax Beginners Area/Code example for saving and loading text data?

Craig H. Nisbet(Posted 2007) [#1]
Anyone got an example of how to open, close and write to text files like in Blitz3D?


degac(Posted 2007) [#2]
'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



grable(Posted 2007) [#3]
You can use LoadText/SaveText as well:
Local s:String = "Hello World!"
SaveText s, "hello.txt"

s = LoadText( "hello.txt")
Print s



Czar Flavius(Posted 2007) [#4]
What does the MilliSecs() do?


xlsior(Posted 2007) [#5]
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.