John Allen's Z88 pages   Z88

Z88 Printer driver

In the April 1988 issue of The Micro User I explained how to use a printer with your Z88, and included a handy little printer server program. This allowed a Z88 to treat a BBC micro as a printer, with the Z88's output subsequently being printed by the BBC micro. What I didn't discuss in that article was how to use the Z88's PipeDream Printer Driver from within Basic programs.

Now why might this be useful? The main reason is all to do with the Z88's portability. Putting effect codes like underline directly into a program means that the program can only be used with one particular type of printer. On a fixed BBC micro this is unlikely to be a problem, but a Z88 is likely to be used with more than one printer, say a dot matrix at home and a daisy wheel in the office. By sending all of the printing through the PipeDream Printer Driver, changing printer is just a matter of loading a new definition file into the Driver.

Using the Printer Driver is not difficult. First off the printer has to be opened in the program in the same way as a file, using the device name :PRT.0 instead of the usual file name, for example:

Then use PRINT#X or BPUT#X to send output to the printer. It is worth mentioning that PRINT# on the Z88 is different to the same instruction on the BBC micro. Each string is sent to the file or device followed by a carriage return, rather than in the BBC micro's 'internal form'. Thus each line sent has to be a single string. In practice this is achieved by converting everything to strings (use STR$ for numbers) and using '+' instead of the normal ',' separator. When you've finished with the printer, like a file, the channel should be closed:
The Printer Driver is activated by a series of commands to the VDU drivers. These are always the number 5 followed by an ASCII code. The first of these commands to use is the one to ensure that the Driver is active. This is:
In this case BPUT# is used to send the two bytes because PRINT# would add a carriage return.

PipeDream printer effects are now possible. Fortunately the codes required are identical to the letter needed after the 'diamond'P in PipeDream for the same effect. I find it easier to define a function 'P' to send these codes via PRINT#:

  DEF FNP(A$)=CHR$(5)+A$
Then if, for example I want to underline I add FNP("U") to the string at the appropriate place. Remember that an effect will be turned off at the end of a line if that's how it is set in the Driver.


Printer Driver Commands

                     BPUT# form   PRINT# form

  Printer Driver on  5,ASC"["     CHR$(5),"["
  Printer Driver off 5,ASC"]"     CHR$(5),"]"
  Underline          5,ASC"U"     CHR$(5),"U"
  Bold               5,ASC"B"     CHR$(5),"B"
  Extended Sequence  5,ASC"X"     CHR$(5),"X"
  Italics            5,ASC"I"     CHR$(5),"I"
  Subscript          5,ASC"L"     CHR$(5),"L"
  Superscript        5,ASC"R"     CHR$(5),"R"
  Alternate font     5,ASC"A"     CHR$(5),"A"
  User Defined       5,ASC"E"     CHR$(5),"E"

© John Allen 2014