demonstrates, how you might print out the heading of a contents page on page 1 of a book (if that book was displayed using ZX Spectrum Next characters of course!)

Try running this:

10 FOR n=0 TO 20
20 PRINT TAB 8*n;n;
30 NEXT n

This shows what is meant by the TAB numbers being reduced modulo X. For a more elegant example, change the 8 in line 20 to a 6 or even try to implement this on a different layer such as the HiRes one as it allows more room for demonstration of this functionality by adding LAYER 1,2 before line 10.

As you'll see in Chapter 20, TAB accepts a two-byte parameter which means it accepts a maximum column number of 65535! Not that you'd ever want to use that!

Some small points:

  1. These new items are best terminated with semicolons, as we have done above. You can use commas (or nothing, at the end of the statement), but this means that after having carefully set up the PRINT position, you immediately move it on again which wouldn't usually be terribly useful.
  2. As a reminder, you cannot print on the bottom two rows (22 and 23) on the Layer 0 screen because they are reserved for commands, INPUT data (see below), reports/errors and so on. References to the bottom line usually mean line 21 and only apply to Layer 0.
  3. You can use AT to put the PRINT position even where there is already something printed; the old stuff will be obliterated when you print more.

CLS

Another statement that's connected with PRINT (although it's not only limited to it), is CLS. This clears the whole screen, something that is also done by CLEAR and RUN. The LAYER command does not clear the screen however, although it may switch to a new screen that has nothing on it. Do not assume a Layer is free of stuff just because you haven't used a command that outputs something on screen. Always give CLS after switching layers if you want to ensure a screen free of anything on it.

Scrolling

When the printing reaches the bottom of the screen, the latter moves its contents upwards, to clear room on the bottom for new content. You can see this if you go into the status area by using the Edit menu option Screen and then type:

CLS:FOR n=1 TO 22:PRINT n:NEXT n

and then do:

PRINT 99

a few times.

Depending on the layer you are on, the computer may pause its screen output for you to review the content being printed and ask you a question or may simply display a block cursor at the lower right corner and wait.

On Layer 0, if the computer is printing out reams and reams of stuff on screen, it asks you before continuing. You can see this happening if you type:

CLS:FOR n=1 TO 100:PRINT n:NEXT n

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.