Chapter 20 - The ZX81 Printer

If you have got a ZX81 printer, you will have some operating instructions with it. This chapter covers the BASIC statements needed to make it work.

The first two, LPRINT & LLIST, are just like PRINT and LIST, except that they use the printer instead of the television. (The L is a historical accident. When BASIC was invented it usually usually used an electronic typewriter instead of a television, so PRINT really did mean print. If you wanted messages of output you would use a very fast line printer attached to the computer, & an LPRINT statement meaning 'Line printer PRINT'.)

Try this program for example.

10 LPRINT "THIS PROGRAM:",,,,

20 LLIST

30 LPRINT ,,"PRINTS OUT THE CHARACTER SET.",,,

40 FOR N=0 TO 255

50 LPRINT CHR\$ N;

60 NEXT N

The third statement, COPY, prints out a copy of the television screen. For instance, get a listing on the screen of the program above, & type

COPY

You can always stop the printer when it is running by pressing BREAK key (space).

If you execute these statements without the printer attached, it should just lose all the output & carry on with the next statement. However, sometimes it might get stuck, & when this happens the break key will bring it out.

Summary

Statements: LPRINT, LLIST, COPY

Note: None of these statements is standard BASIC, although LPRINT is used by some other computers.

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.

Previous: Chapter 19    Next: Chapter 21