10 x=NEXT #0

which does the same thing!

COPY filespec TO #n

We've seen this command sequence before in a shortcut which did not include a stream number but rather a keyword: SCREEN$. In that case n is the stream to channel s which by default is #2. When used with a stream number, COPY...TO #n, can be used to transfer the contents of a file to a stream. For example to write the extended version of COPY "c:/readme.md" TO SCREEN$ we should type:

COPY "c:/readme.md" TO #2

When NextBASIC is running, it has four streams normally open. Streams #0 and #1 are connected to the keyboard (channel k), and are used by INPUT and INKEY$. Stream #2 is connected to the screen (channel s), and is used by PRINT, LIST, CAT and PWD, commands in other words that print something to the screen. Stream #3 is connected to the printer (channel p), and is used by LPRINT, LLIST and COPY (without parameters). All of these commands can be redirected to use another device by including a # followed by an open stream number, so

PRINT #1;"This is the lower screen"

will print the message on the lower screen while

PRINT #3;"Who needs LPRINT, Romulus?"

will use the printer. Conversely, LPRINT can behave like PRINT and typing:

LPRINT #2;"Are you confused yet Roy?"

makes LPRINT #2 do what PRINT normally does.

Notes

INPUT # may be used with other channels other than k and w such as file(i,o,u), memory (m) and variable (v) channels. In these cases, it is advisable to avoid any accidental outputs to the channels, by not using any prompt strings, and by using only the semicolon as a separator. In most cases, you will want to input a string using the LINE (See Chapter 14) modifier as without this, the data in the file (or other channel) would need to be surrounded by quotes.

The Variable and Memory Channels

In the previous chapter, we've examined a special dot command (.$) that allowed NextBASIC to talk to any dot command not made specifically to interact with it. The Variable and Memory Channels can be seen as facilitating the reverse flow of information; to get information from the outside world into NextBASIC. They both involve reserving some space beforehand to accept the input but they differ in the sense that the former can be moved anywhere in memory (as variables could be stored anywhere) while the latter is a fixed location (which makes it more suitable for use by machine code programs). You may remember the series of commands we used to get the output of PWD in Chapter 19 or .time in Chapter 17. Let's remember them quickly:

DIM d$(255):OPEN #2,"v>d$":.cd --verbose:
CLOSE #2: PRINT d$

and


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.