READCHARS

Synopsis
READCHARS number
RCS number
Description

Reads number characters (or bytes) from the read stream and outputs them as a word.

If the read stream is a file that was opened in text mode, then READCHARS reads number characters from the file according to whatever character encoding was detected when the file was opened. If the read stream is a file that was opened in binary mode, then READCHARS reads number bytes from the file and outputs a word where each character uses the code point of the corresponding byte (0 - 255). If the read stream is the Commander, then READCHARS reads nothing and outputs the empty list.

If number is larger than the number of characters (or bytes, for binary files) remaining in the read stream, then READCHARS outputs the rest of the read stream. If the read stream is a file and there are no unread characters in the file, then READCHARS outputs the empty list (not the empty word).

Backslash, vertical bar, and tilde characters have no special meaning in this context.

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

OPENREAD "example.txt
SETREAD "example.txt
SHOW READCHARS 5
Hello
SETREAD []
CLOSE "example.txt

SourceForge.net Logo