|
stream - a file stream opened for writing, or a TCP stream string$ - text to write |
|
Writes a line of text to a file or stream. The string is written as-is, followed by a Windows-style end-of-line (carriage return + linefeed). This is how you produce plain text files people can open in any editor - readable config files, log files, exported level data. Read them back with ReadLine. For data files where exact strings matter more than human readability, WriteString is the safer pair, since it stores the string's length instead of relying on line breaks. See also: ReadLine, WriteString, WriteFile. |
; WriteLine Example
; -----------------
; WriteLine writes a line of text followed by a line ending -
; ideal for plain-text save files you can open in any text editor
file=WriteFile("demo_savegame.txt")
WriteLine file,"player=Robo"
WriteLine file,"score=11657"
WriteLine file,"level=7"
CloseFile file
Print "Wrote 3 lines to demo_savegame.txt:"
; Read them back to show what was written
file=ReadFile("demo_savegame.txt")
While Not Eof(file)
Print " "+ReadLine$(file)
Wend
CloseFile file
; Clean up the demo file
DeleteFile "demo_savegame.txt"
Print "Deleted demo_savegame.txt"
Print ""
Print "Press any key to close the example"
WaitKey
End