EUG PD


The Great Printer Code Mystery

Categories: Review: Printer

 
Author: Thomas Boustead
Published in EUG #7

Printout Problems

Having just read EUG #6, I conclude there are some among our fellow electroneers who are still having difficulty in getting their printers to produce their text in the styles they desire. I did submit a short BASIC program demonstrating the user of these codes for publication in EUG #6 but "it failed to catch the speaker's eye".

However, that was merely a practical demonstration of the use of codes whereas there does seem some desire for an understanding of the principles. It's a big subject that could well be expanded to occupy the whole of the next twelve issues of EUG!!

ASCII Codes

Those who have printer manuals will be aware that they are rather voluminous publications. I believe a lack of understanding of the need for the codes to be entered in the dialect of the BASIC language used by the computer is possibly a cause of trouble.

In our case, we are concerned with the "BBC" dialect. Printers are built to a standard set of characters known by the acronym "ASCII" (American Standard Code for Information Interchange). Most printers also have supplementary characters to meet the requirements of specific National languages.

In order to be able to work together, the computer and the printer need to understand a common "language" or "code".

Basically the computer needs to be given an instruction which it converts into binary form for transmission to the printer. In our case in order to send information to the printer we input VDU1; this is interpreted by the VDU driver in the computer operating system as an instruction to send what follows to the printer in binary form.

That which follows may be a one-byte control code or a multi-byte control code. These codes are usually in their decimal form (DEC) but are often given in manuals in the three forms. i.e. binary, decimal and hexadecimal. These codes may be pre-fixed ESC. Don't be misled by the appearance of this abbreviation - it is nothing to do with the ESCAPE key on your computer!! In BBC BASIC it is replaced by 1,27 and normally only features when inputting multi-byte codes (sometimes referred to as Escape Sequences).

Differing Dialects

As an example of the differing dialect requirements we can take the code for Enlarged Printing. If my memory serves me well, in the case of the renowned Spectrum, the code would be LPRINT CHR$(27);CHR$(87);CHR$(1) but the BBC equivalent is VDU1,27,1,87,1,1. The significant numbers are the last 1 but it is necessary to preface each significant number by the figure 1.

It should be noted that some codes need to be cancelled before a different code can be effective. Some codes, e.g. VDU1,14 which calls up Enlarged Characters, are self-cancelling at the end of the current line. This is useful for headings for it obviates the need to cancel VDU1,14 before carrying on with printing in the previous style.

If you need to continue in Enlarged Characters beyond the current line then you use the code VDU1,27,1,87,1,1 which is a multi-byte code and so 27 appears in the code. The last 1 is the instruction to implement the code. To stop the Enlarged Characters the code is repeated but the last 1 is changed to 0.

This technique of changing the last numeral from 1 to 0 and vice versa is often used for implementing and cancelling codes. Remember that if you are operating in the non-word-processing mode you will need to include a line in your program VDU2 to open up communication between your computer and its connected printer.

You will appreciate that using these codes direct from the keyboard is a very simple way of styling text but of course there is the limitation on the amount of text which can be input into each line of your program. The style you set can be changed as often as you like by calling it up on a discreet line. You can see how this works from a study of the BASIC program which I referred to in the beginning of this article.

Having only a simple Electron system (Console, Plus 1 and Plus 3), I use BASIC to create headings for Newsletters and then change over to View for the text when of course I have to introduce the Printer Driver.

Basic Printer Headings

One of the advantages of using BASIC to create headings is that one can generate special characters and subject them to the printer code technique. For a newsletter which I publish on behalf of an Association having a nautical flavour I frame the heading in a series of "own characters" simulating an anchor. This is probably very "old hat" to our readers using sophisticated DTP methods but it is clear to me from the Letters pages that there are some among us who wish to do simple things with basic (ooh!) tools.

The same codes, but less the VDU1 and 1s, are used for generating a Printer Driver for use with a word-processing system e.g. for italic characters input 27,52; for underlining input 27,45,1; to switch off underlining input 27,45,0.

N.B. Note that the 1 here is a part of the code to toggle on and 0 is to toggle off as opposed to the 1s used in BASIC as separators. However, there is a limitation on how many highlights can be generated in any one specific driver. The generator program given in EUG #3 is limited to sixteen codes but you can of course create several drivers having differing groups of codes to suit the style of documents you are accustomed to preparing. I would expect the codes I have listed in the appendix to this article should meet the requirements of most Electroneers.

I hope that the foregoing together with the appendix will be of help to those of our friends who have printing problems.

Electron Printer Codes

These are the codes most likely to be required for normal BASIC programming and for use when generating Printer Drivers. You will find many, many more in your Printer Manual but you will need to use them in the BBC language form.

VDU1,10 Line feed
VDU1,12 Form feed
VDU1,13 Carriage return
VDU1,14 Enlarged characters to end of line
VDU1,15 Condensed character ON
VDU1,18 Condensed character OFF
VDU1,20 Cancel Enlarged character before end of line
VDU1,27,1,45,1,1 Underline ON
VDU1,27,1,45,1,0 Underline OFF
VDU1,27,1,52 Italic characters (Alternate mode) ON
VDU1,27,1,53 Italic characters (Alternate mode) OFF
VDU1,27,1,69 Emphasised printing ON
VDU1,27,1,70 Emphasised printing OFF
VDU1,27,1,83,1,0 Set Superscript
VDU1,27,1,83,1,1 Set Subscript
VDU1,27,1,84 Cancel Superscript or Subscript
VDU1,27,1,87,1,1 Enlarged printing not cancelled by line feed
VDU1,27,1,87,1,0 Cancel Enlarged printing
VDU1,27,1,81,1,n Set Right margin to position "n"
VDU1,27,1,108,1,n Set Left margin to position "n"
VDU1,27,1,82,1,n Select International Character set "n"
For example, if you want the "hash" sign "n" is 0 but if you want the Pound sign "n" is 3
VDU1,27,1,33,1,n Set print mode to "n" (between 0 and 63)

If the code for a desired print style is not listed here, you should consult your Printer's User Manual.

Good luck to all '93 Caxtons!

A Final Note

N.B. Remember that when operating in BASIC from the keyboard you must enter VDU2 to enable the Printer and VDU3 to disable the Printer. When operating from within a BASIC program you can use VDU1,17 and VDU1,19 respectively.

Tom Boustead

Thomas Boustead