ZX 81 - BASIC Programming

Sinclair ZX Spectrum
Chapter 20.2 - The ZX81 Printer

Exercises

1. Try this:

10 FOR N=31 TO 0 STEP -1

20 PRINT AT 31-N,N;CHR$ (CODE "0" +N);

30 NEXT N

You will see a pattern of letters working down diagonally from the top right-hand corner until it reaches the bottom of the screen, when the program stops with error report 5.

Now change 'AT 31-N,N' in line 20 to 'TAB N'. The program will have exactly the same effect as before.

Now change PRINT in line 20 to LPRINT. This time there will be no error 5, which should not occur with the printer, & the pattern will carry on an extra ten lines with the digits.

Now change 'TAB N' to 'AT 21-N,N' still using LPRINT. This time you will get just a single line of symbols. The reason for the difference is that the output from the LPRINT is not printed straight away, but arranged in a buffer store a picture one line long of what the computer will print when it gets round to it. The printing takes place

    (i) when the buffer is full,

    (ii) after an LPRINT statement that does not end in a comma or semicolon.

    (iii) when a comma or TAB item requires a new line.

or

    (iv) at the end of a program, if there is anything left unprinted.

    (iii) explains why our program with TAB works the way it does. As for AT, the line number is ignored & the LPRINT position (like the PRINT position, but for the printer instead of the television) is changed to the column number. An AT item can never cause a line to be sent to the printer. (Actually, the line number after AT is not completely ignored; it has to be between -21 & +21 or an error will result. For this reason it is safest always to specify line 0. The item 'AT 21-N,N' in the final version of our program would be much better albeit less illustrative if replaced by 'AT 0,N'.)

2. Make a printed graph of SIN by running the program in chapter 18 & then using COPY.

Sinclair ZX Spectrum

  Previous Page Back Next Page