ResiDOS provides built-in support for accessing new extended channels in addition to the three standard ("K", "S" and "P") channels. Streams can be opened and closed using the normal OPEN # and CLOSE # commands (and ResiDOS also fixes the bug with the Spectrum's CLOSE # command so that it is safe to use). Machine-code programmers also have comprehensive access to these extended channels (see the programming section for details).
Once a stream is open to a channel, you can send output to it and receive input from it using any standard Spectrum BASIC command that allows a stream number to be specified. Additionally, most ResiDOS commands that display output may be redirected to a stream, allowing you to capture and manipulate such information. For example, any of these commands are allowed:
Additionally, ResiDOS provides two additional functions and a command to read/write the current position in the stream, and to read the size of the stream (not all channels support these operations):
ResiDOS does not actually provide any extended channel types itself; these may be provided by various optional packages. The most important of these is the channels package, which you are encouraged to download and install.
ResiDOS uses the following commands for manipulating streams and channels:
This command opens a stream to a channel. The value of stream can be any number from 0 to 15; if one of the standard streams (0-3) is specified, then its original assignment is replaced with the new channel specified. The value of c$ is either a single character representing one of the Spectrum's standard channels ("K", "S" or "P"), or a string specifying a new extended channel.
The exact form of the channel specifier is documented separately for each new channel provided, but generally it consists of a letter followed by a ">" character; optionally, there may be further parameters inside the string (usually separated by commas). If you want to calculate a value for a parameter, this is perfectly possible - just remember to use the STR$ function to build up the string.
For example, to open stream 5 to a region of memory specified by the variables addr and len, use the following command:
OPEN #5, "m>" + STR$ addr + "," + STR$ len
This command closes a stream, flushing any output that might be buffered. If the stream was one of the standard streams (0-3), then it is re-assigned to its default channel (ie "K" for streams 0 & 1, "S" for stream 2 and "P" for stream 3).
For example, to close stream 5:
This function returns the current position of the the pointer in the stream specified. Not all channels support this function; see the documentation for individual channels.
For example, to find the position of the pointer in stream 5:
LET pos=FN ptr#(5)
This function returns the extent (size) of the stream specified. Not all channels support this function; see the documentation for individual channels.
For example, to find the size of stream 5:
LET size=FN ext#(5)
This command sets the current position of the pointer for the stream specified. Not all channels support this function; see the documentation for individual channels.
For example, to set the pointer to the start of stream 5:
POINT #5, 0
Back to the ResiDOS homepage