1160 IF mode=5 THEN LAYER 2,1:
CLS:PRINT CHR$ 30;CHR$
ch:PRINT CHR$ 29; CHR$
he:PRINT AT
0,0;"Layer2"'"CSIZE (HxW)
";h;" x ";chsz'"PRESS ANY
KEY":PAUSE 0:CLS:ENDPROC
SCREEN$ is the reverse function to PRINT AT, and will tell you (within limits) what character is at a particular position on the screen. It uses line and column numbers in the same way as the Layer 0 version of PRINT AT, but enclosed in parentheses. For instance:
PRINT SCREEN$ (11,16)
will retrieve the star you printed in the first example of the previous section. SCREEN$ only works on Layer 0 and will return everything printed there, even if you switch layers during the process as long as the memory used (which is shared between Layers 0, 1 and 3 as you will see in Chapter 23) has not been overwritten by another display related command. Type:
10 LAYER 0:PRINT AT 11,11;"*"
20 LAYER 1,0:PRINT AT
0,0;SCREEN$ (11,11)
You will get a huge * on the upper left corner of your screen even if the original * is not visible anymore on screen. Changing line 10 to LAYER 1,0 from LAYER 0 will produce a null string.
Characters taken from tokens print normally, as single characters, and spaces return as spaces. Lines drawn by PLOT, DRAW or CIRCLE, user-defined characters and graphics characters return as a null (empty) string, however. The same applies if OVER (See Chapter 16) has been used to create a composite character. The way that SCREEN$ works is that it matches the character in a screen location to the bitmapped image of the character in the ROM of NextZXOS. If they match it will return it. If the picture in the location doesn't match any known character it will return an empty string.
If you're familiar with word processing, other computers, or even typewriters, you may be also familiar with the concept of a tab, or tabulating character. What this does in other computers is to insert a special character which will move the cursor right by a predetermined amount of locations in order to arrive to a specific column in your text. The ZX Spectrum Next, doesn't quite work like this although the ending result on your screen is pretty much equivalent. The modifier:
TAB column
prints enough spaces to move the PRINT position to the column specified. It stays on the same line, or, if this would involve backspacing, moves on to the next one. Note that the computer reduces the column number modulo X with X being the maximum amount of columns available per the width of character chosen for each Layer (meaning it divides by X and takes the remainder); so for example for Layer 0, TAB 33 means the same as TAB 1.
The code:
PRINT TAB 30;1;TAB 12;"Contents"; AT
3,1;"CHAPTER";TAB 24;"page"
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.