SETREADPOS

Synopsis
SETREADPOS bytepos
Description

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

SETREADPOS 0 starts reading 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 SETREADPOS 0 sets the read position to just after the byte order mark. This is still conceptually the beginning of the file.

If the read 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 read stream's position to the middle of a character is likely to have undesirable results. Therefore, it's advisable to only run SETREADPOS with an input that was previously output from READPOS.

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

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

OPENREAD "example.txt
SETREAD "example.txt
SHOW READLIST
[Hello]
SETREADPOS 0
SHOW READLIST
[Hello]
SETREAD []
CLOSE "example.txt

SourceForge.net Logo