Chapter 21: The ZX printer

BASin

Chapter 21: The ZX printer

Summary

LPRINT, LLIST, COPY

Note: Using the ZX Printer support in conjunction with certain 128k commands can have undersirable results. See the section on BASin and the 128k Spectrum for more details. If you are making use of 128k commands, you should avoid the use of the ZX Printer.

This chapter covers the BASIC statements needed to operate the ZX printer.

BASin emulates the ZX printer: you can view, save, and print the results from the ZX printer output window.

The first two statements, LPRINT and LLIST, are just like PRINT and LIST, except that they use the printer instead of the television. (The L is an historical accident. When BASIC was invented it usually used an electric typewriter instead of a television, so PRINT really did mean print. If you wanted masses of output you would use a very fast line printer attached to the computer, and 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=32 TO 255
50 LPRINT CHR$ n;
60 NEXT n

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

COPY

Note that COPY doesn't work with one of the listings that the computer puts up automatically, because that is cleared whenever a command is obeyed. You must either use LIST first, or use LLIST and forget about COPY.

You can always stop the printer when it is running by pressing the Esc key.

If you execute these statements without the printer attached, it should lose all the output and carry on with the next statement.

Try this:

10 FOR n=31 TO 3 STEP -1
20 PRINT AT 31-n,n; CHR$ (CODE "3"+n);
30 NEXT n

You will see a pattern of characters working down diagonally from the top right-hand corner until it reaches the bottom of the screen, when the program asks if you want to scroll.

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 scroll?, which should not occur with the printer, and the pattern will carry straight on with the letters F to O.

Now change TAB n to AT 31-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 PRINT is not printed straight away, but arranges in a buffer store a picture one line long of what the computer will send to the printer when it gets round to it. The printing takes place

  1. when the buffer is full,
  2. after an LPRINT statement that does not end in a comma or semicolon,
  3. when a comma, apostrophe or TAB item requires a new line, or
  4. 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 and 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.

Exercise

  1. Make a printed graph of SIN by running the program in Chapter 17 and then using COPY.

Chapter 22

Chapter 20