Windows, are defined by their top line (0-23), leftmost column (0-31), height (1-24), width (1-32), and optionally character size (3-8) and character set address. If no character size is specified, the default is 8. If a character set address is given, then this is used instead of the built-in fonts; this allows you to use nice fonts such as those provided with art programs and adventure games. Due to their complexity, we'll devote an entire section to Windows after we discuss streams and the commands with which we use them.

Streams

Streams3 are convenient ways for the computer to switch between channels by referring to them as numbers. This idea makes it possible to write programs that can send information to any device without having to use different commands. There are 16 total available streams numbered 0 to 15. 4 streams; 0 through 3, as seen on the table above, are already opened to channels k,s and p. Note here, that many streams can be attached to a channel depending on what we want to do.

Using Streams

All the above might seem complicated, and you may well wish to stick to the standard PRINT and INPUT commands – that's why they're there after all. Even these commands however, are just shortcuts to their "complete" versions that also include a stream number and the benefits of using channels far outweigh their perceived complexity.

Stream control commands

Since it's now evident that any device on the computer that accepts input or produces output is really a channel, it's easy to realise that we have been using streams all along; we've already visited PRINT and LPRINT (which are really the same command), used INPUT and INKEY$ and lastly, we've used LIST and LLIST (which also are the same command). All the above, have versions which include a # (hash) followed by a current stream number, so we are already halfway there!

Apart from these and OPEN # we saw in the channels section above, the following commands are available for working with streams: CLOSE #, DIM #..., DIM #...TO, NEXT #..., NEXT #...TO, POINT #..., RETURN #...TO, GOTO #...TO and COPY ...TO #, CAT # and PWD #. We'll examine them all below:

OPEN #n, channelspec

where n is the stream number4 and channelspec is a string that can be any of the following (capitals or lower case letters may be used), opens a stream and attaches it to the channel defined by channelspec:

String Description
"k" The standard input channel (keyboard and lower screen). Streams 0 & 1 are normally set to this channel
"s" The standard output channel (main screen). Stream 2 is normally set to this channel.
"p" The standard printer channel (serial or parallel). Stream 3 is normally set to this channel.
"i>filespec" This opens an input-only stream to an existing file. If the filename is at least two characters long, you can omit the "I>" as this will be assumed (single-character names require the "I>" as otherwise they will be assumed to be standard channel names).
"o>filespec" This creates a new file and opens an output-only stream to it.

3 On other versions of BASIC, streams are called channels and channels are called devices. This may be a bit confusing to a user coming from a different flavour of BASIC. The concepts however are basically the same. 4: Altering streams 0 to 3 will change the behaviour of the system and should be used with care.


ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.