John Allen's Z88 pages   Z88

Z88 Printer server

This page is archived and no longer maintained


Having a computer like the Z88 is all very well but for it to be useful you need to be able to get some sort of printed output from it. One of the ways to do this (described in Micro User January 1988) is to transfer files to a BBC micro, format them with a word-processor, then produce the output on the BBC's printer. This can be a lot of trouble, but connecting a printer directly to the Z88 means another lead which, if it only has a parallel interface, is costly and generally involves fiddling with those tiny dip switches hidden inside the printer. This article describes another approach, using your BBC as a slave to the Z88.

If you are able to transfer files you already have a serial lead to connect the two machines together. This means that you can use it to join the serial ports together, run our handy little Printer Server Program and whenever you go to print on the Z88 the output appears on the BBC's parallel printer. This approach has another advantage - it helps you to avoid a bug in the Z88's Pipedream Printer Driver, more on that later.

The program to make the BBC micro do this is very simple. What it does is to take the data being sent from the Z88 and sends it to the printer using the normal BBC printer options. Straightaway you can use Pipedream highlights (such as bold or underline) and effects (like centring) without needing to have the BBC micro View Professional package.

To use the program, first select the Z88's Panel utility (with 'square' S). The transmit speed needs to be set to 9600, Parity should be NO and Xon/Xoff should be NO. The program is then run on the BBC micro. The ESCAPE key will stop it when printing is finished.

Pipedream

As I hinted earlier the Z88 Printer Driver has a rather nasty bug. This means that the option to print without sending line feeds does not work. In fact, selecting that option sends null characters (i.e. 0) at the end of lines in place of line feeds and carriage returns. This means that the driver can only be set so that "Allow line feed" is YES in order to get anything meaningful on any printer.

On a BBC micro, by default, all line feeds (character 10) are filtered out when characters are sent to the printer. This means that one of the dip switches in the printer has to be set to make the printer automatically feed a line whenever it does a carriage return. As double spaced text, for example, is sent to the printer by Pipedream with one carriage return followed by two line feeds between each line of text, the server program checks for these multiple line feeds and makes sure that all line feeds are matched with a corresponding carriage return.

BASIC

The Z88 uses BBC Basic as the programming language but as the hardware, such as the printer, is controlled in a different way, *FX3 and the VDU command do not have any effect on the printer (indeed the *FX command does not exist).

In Z88 BBC Basic there are two main ways to send output to a printer (and so to the BBC micro acting as a printer server - the Z88 cannot tell the difference). The screen output can be redirected so that it also goes to the printer (the equivalent of CTRL-B or VDU2 on the BBC) or, and this is an additional feature of Z88 BBC Basic, the printer can be opened as an output file and data can be printed in the same way as writing to a file. By opening the printer as an output file you have independent control of screen and printer output.

To look first at the easiest option: redirecting all screen output to the printer. This is done by entering 'square'+P from the BASIC command prompt before running the program. After the program has finished the redirection can be cancelled by entering 'square'-P. This is similar to using CTRL-B and CTRL-C on the BBC micro. When printing in this way the Z88 Printer Driver is used for things like printer setup. This method does however send all sorts of control codes to the printer whenever you enter characters from the keyboard which, on most printers produces messy output.

To redirect just some of the output under the control of a program (the equivalent of using VDU2 and VDU3 on the BBC) use can be made of one of the Z88's (undocumented) "*" commands, *CLI. This command allows use of the Z88's operating system, using the CLI commands in the Filer.

To do this first set up two files using Pipedream, each should be saved as plain text. The first, with the name of PRINTERON, containing the two lines:

  #+P
  .S
The second file, called PRINTEROFF, should contain:
  #-P
  .S
In order to turn the printer on during a program (the equivalent of VDU2) use:
  *CLI .*PRINTERON
  DUMMY=INKEY(0)
What is happening is that the *CLI command runs PRINTERON as a command file this redirects output and closes the CLI down, retaining the redirection. The INKEY statement is a dummy statement (in other words a bodge) which forces an interrupt to occur on the Z88 so that the *CLI command is executed immediately, otherwise the Z88 waits until the end of the program before executing it (this is not very useful). Similarly to turn the printer off during the running of a program use:
  *CLI .*PRINTEROFF
  DUMMY=INKEY(0)
To take the other approach: opening the printer as a file, you need to use the device ":COM.0" (the serial port) in place of the filename in an OPENOUT statement. This statement would then become something like:
  X%=OPENOUT":COM.0"
After that data can be sent to the printer using BPUT#X% or PRINT#X%. When there's nothing more to print the channel is closed with CLOSE#X%.

The action of PRINT# on the Z88 is not the same as on the BBC micro. On the BBC micro everything is stored in what Acorn call an "internal format" a consequence of which is that any output would be meaningless on a printer. On the Z88 PRINT# sends strings in the same way as PRINT (except that each string is always followed by a carriage return) but only the low bytes of numbers are send as with BPUT#.

Integer and real numbers can be printed using PRINT# with the Basic STR$ function. This takes a numerical argument and converts it to a string. Thus:

  PRINT#X%,STR$(100.37) 
after the printer has been opened on channel X% would print "100.37" followed by a carriage return. To print "The number is 100.37" you would use the instruction
  PRINT#X%,"The number is "+STR$(100.37)
Note that "+" has been used between the strings to prevent a carriage return being sent before the number.

If your printer needs a line feed to be sent, as well as the carriage return, the last item in each PRINT# statement has to be "+CHR$(10)".

Finally, since you can run BBC Basic programs on the BBC Micro, what's the advantage of running them on the Z88? Three come to mind straightaway: if you want to make use of Z80 processor machine code, if you want to use data stored on the Z88 and probably most important if you need more space. The Z88 gives Basic up to 40k of memory, an enormous increase in the size of arrays and programs possible.


PipeDream Page Layout Tip

Pipedream (and indeed View Professional) assumes that the page layout is correctly calculated by the user. If you want double spacing, the margins (top, header, footer and bottom) together with any headers and footers add up to an even number of lines to insert at the top and bottom otherwise Pipedream will print 1 line more than the page length.

To get no page breaks set Page Length to 0, the other alternative of setting the length to a high number will cause strange things to happen in Pipedream if the number is greater than 255.


BASIC * Commands

Z88 BBC Basic contains four '*' commands:

  • *CLI (Filer CLI instruction) this allows access through Basic to the CLI commands in the Filer.
  • *DELETE (filename) or *ERASE (filename) does the same as *DELETE on the BBC.
  • *RENAME (file1) (file2) renames a file in the same way as *RENAME on the BBC.
All of these commands can be used either in command form after the Basic prompt or within programs. Within programmes the same rule about "*" commands having to be the last statement on a line applies as on the BBC, but this can be avoided by using OSCLI and putting the command in a string e.g.
  OSCLI "DELETE FILE1"
In a program *CLI is only executed after an interrupt so it should be followed by a statement which forces one (like INKEY).

Click here to download PRINT (zip file)

© John Allen 2014