(Just press ENTER each time it stops.) When This is line 2. is printed, the lower part of the screen moves up to make room for it; but the numbering moves up as well, so that the rows of text keep their same numbers.
Now try this (again on Layer 0):
10 FOR n=0 TO 19: PRINT AT
n,0;n;: NEXT n
20 INPUT AT 0,0;a$; AT 1,0;a$;
AT 2,0;a$; AT 3,0;a$; AT
4,0;a$; AT 5,0;a$;
As the lower part of the screen scrolls up and up, the upper part is undisturbed until the lower part threatens to write on the same line as the PRINT position. Then the upper part starts scrolling up to avoid this.
The other layers work in the same manner as described for PRINT items, that is in both rigid (cell matrix) and flexible (pixel coordinate) terms. To illustrate the difference, issue a LAYER 1,1 direct command and then modify the first example by first copying line 10 to line 20 and then changing all AT statements to POINT statements switching the x and y positions around, thus making the latter two parameters 0,16 and 0,8 respectively to reflect the height of characters (remember that on layers other than 0 character matrices will change according to character size and pixel positioning according to max resolution).
The first thing you'll notice is that INPUT takes place at the top left of the screen as would with PRINT and the second one that the first INPUT item is NOT printed at "line" 1 but rather at "line" 0. Finally you can see from the modified first example that INPUT accepts a POINT modifier for positioning exactly like PRINT does.
Another refinement to the INPUT statement that we haven't seen yet is called LINE input and is a different way of inputting string variables. If you write LINE before the name of a string variable to be input, as in:
INPUT LINE a$
then the computer will not give you the string quotes that it normally does for a string variable, although it will pretend to itself that they are there. So if you type in:
Simon
as the INPUT data, a$ will be given the value Simon. Because the string quotes do not appear on the string, you cannot delete them and type in a different sort of string expression for the INPUT data. Remember that you cannot use LINE for numeric variables.
There's an interesting capability of INPUT. While typing into an INPUT request that's expecting a number variable, you can use numeric expressions which can include previously defined variables. Try running this program:
10 a=14
20 INPUT numbers
30 PRINT numbers
40 GO TO 20
Input a few numbers, and they'll be printed as expected on the screen. Now type a and if you press ENTER, then 14 will appear! Try typing a+2 and 16 will appear. However, if you
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.