Writeline
Writeline (Statement)
Format
writeline string_expression
writeline ( string_expression )
writeline open_file_number, string_expression
writeline ( open_file_number, string_expression )
Description
Writes string_expression followed by a line ending to an open file, at the place of the file pointer, and moves the pointer to just after what was written. If the file number is not specified file number zero (0) will be used.
Open puts the file pointer at the beginning of the file, so writing to a file that already holds text overwrites it from the start. To add lines after the text that is already there, move the pointer to the end first with seek size (see Seek and Size). To throw the old text away and start again, use Reset.
In a file opened with Open the line ending is the one the operating system uses: on Windows it is two characters, a carriage return and a line feed, elsewhere a single line feed.
Example
open "list.txt"
reset
writeline "apples"
writeline "bread"
close
open "list.txt"
# without this seek, writeline would write over "apples"
seek size
writeline "cheese"
seek 0
while not eof
print rtrim(readline)
end while
close
will print
apples
bread
cheese
See Also
Changedir, Close, Currentdir, Dir, Eof, Exists, Freefile, Kill, mkdir, Open, Openb, OpenFileDialog, OpenSerial, Read, Readbyte, Readline, Reset, SaveFileDialog, Seek, Size, Write, Writebyte, Writeline
History
| 0.9.4 | New To Version |