OPENAPPEND

Synopsis
OPENAPPEND filename
(OPENAPPEND filename binarymode)
Description

Opens the file named filename for writing. If a file with the given filename already exists, the write position is initially set to the end of the old file, so that newly written data is appended to it. If no file with the given filename exists, then OPENAPPEND creates an empty file.

If the filename input is the reserved word "clipboard, then you can append text data to the clipboard as if it were a file. If the clipboard doesn't contain text when it is opened, then it's treated as if it contained nothing (you start appending at the beginning). If the clipboard is opened for appending in binary mode, then you must encode the text that you append in UTF-8. Even in binary mode, only text data can be written to the clipboard.

The optional binarymode input is a boolean value (TRUE or FALSE). If binarymode is FALSE or not given, then the file is opened as a text file. If binarymode is TRUE, then the file is opened as a binary file.

When opening a text file, OPENAPPEND infers the character encoding from the existing file's Unicode signature, a byte order mark (BOM) that is at the beginning of the file. OPENAPPEND only recognizes two Unicode character encodings: UTF-8 and UTF-16LE. If there is no Unicode signature or if the Unicode signature is not recognized, then an existing file is assumed to be encoded in the system default Windows code page. If the file doesn't exist, then OPENAPPEND creates a new file with a UTF-8 BOM and characters are written as UTF-8. In addition, when appending to a text file, the end-of-line sequence is converted from LF to CRLF.

When appending to a binary file, the data is written as bytes (values from 0 - 255) and no end-of-line sequence conversion is performed.

Example
OPENWRITE "example.txt
SETWRITE "example.txt
PRINT "Hello
SETWRITE []
CLOSE "example.txt

OPENAPPEND "example.txt
SETWRITE "example.txt
PRINT [Good Bye]
SETWRITE []
CLOSE "example.txt

OPENREAD "example.txt
SETREAD "example.txt
REPEAT 2 [SHOW READLIST]
[Hello]
[Good Bye]
SETREAD []
CLOSE "example.txt
See Also
CLOSE

SourceForge.net Logo