Similar things apply to the Keyboard Channel. This is already connected to two streams: #0 and #1 as we can see by the following little program:

10 INPUT #0;"Stream 0 Input: ";a$
20 INPUT #1;"Stream 1 Input: ";b$
30 PRINT a$'b$

The Printer Channel is also simple and by default attached to stream #3. As a matter of fact, giving **PRINT #**3 is basically a default2 longhand for LPRINT and similarly LLIST is basically the same as LIST #3.

Notes

As streams #0 to #3 are predefined and already opened, altering these may also alter the behaviour of the system, therefore you are advised to avoid the practice unless you exercise care.

Where things start to differentiate a bit is with the Files Channel. Firstly, no file channel is by default open, and secondly any file can be opened in 3 modes: Input, Output and Update (Input/Output). As the names imply, Input will only accept data FROM a file, Output will only direct data TO a file and Update will allow input and output of data TO and FROM a file. There are a couple of special considerations regarding file channels:

  • You should always take care to close streams that have been opened to a file in Output or Update modes when you have finished, as otherwise data loss may occur. It is always good practice to do this even for files opened in Input mode (or streams open to other channels). The CLOSE command will be examined further below.
  • Files saved by CP/M or a +3e, are usually stored as a number of 128-byte records and so you may read rubbish at the end of a file that comes from such a system if it is not an exact multiple of 128 bytes in length. NextZXOS however, reports proper file sizes and does not suffer from this problem even when it saves files on a +3DOS/IDEDOS drive.

File channels support all the pointer commands (more on these further below).

The Variable Channels can be used to direct output to or input from a string variable, which can be easily manipulated within a NextBASIC program. This would allow you to (for example) examine disk catalogues in your NextBASIC program, or make an auto-running game demo (by inputting from a string containing set keystrokes). The string specified must be a character array with a single dimension, large enough to hold the maximum amount of data you expect to have to deal with.

Variable Channels also support all the pointer commands.

The Memory Channel can be used in a very similar way to the Variable Channels. However, as it is a fixed memory region, it is more suitable for use by machine-code programs. It also requires you to reserve the memory beforehand.

The Driver Channels are special channels to exchange data with Device Drivers. Not every Device Driver can be addressed by a Driver Channel and not all Driver Channels have all options or can even access pointer commands. You will need to refer to each driver's documentation in order to know what is supported and what isn't.

Finally the most complicated Channels of all are the Windows Channels. Although they do not support any of the pointer commands, they are extremely flexible as they accept a large number of control codes as we've briefly mentioned in Chapter 14.

2 Default means in this context: "without parameters". As we will see further below, even LPRINT and LLIST behaviour can change


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.