SETWRITEPOS

Synopsis
SETWRITEPOS bytepos
Description

Sets the file pointer of the write stream's file so that the next PRINT, etc., begins writing at the bytepos-th byte in the file, counting from 0.

SETWRITEPOS 0 starts writing at the beginning of the file. However, if the file was opened in text mode and has a byte order mark at the beginning, then SETWRITEPOS 0 sets the write position to just after the byte order mark. This is still conceptually the beginning of the file.

If the write stream's file was opened in text mode, then, depending on the file's character encoding, a single character may occupy one or more bytes. Setting the write stream's position to the middle of a character is likely to have undesirable results. Therefore, it's advisable to only run SETWRITEPOS with an input that was previously output from READPOS or WRITEPOS.

SETWRITEPOS is meaningless and has no effect when the current write stream is [] (the Commander).

Example
OPENWRITE "example.txt
SETWRITE "example.txt
PRINT "Hello
SETWRITEPOS 0
TYPE "J
SETWRITE []
CLOSE "example.txt

OPENREAD "example.txt
SETREAD "example.txt
SHOW READLIST
[Jello]
SETREAD []
CLOSE "example.txt

SourceForge.net Logo