EUG PD


Controlling A Printer From Basic

Categories: Review: Printer

 
Author: Gus Donnachaidh
Published in EUG #30

In my job, one of the things I have to do is to test installations and make out a form to a prescribed format with all of the details.

The sample layout in the IEE manual has a number of lines in condensed print as well as a lot of spacing and symbols incorporating subscript and super script.

I initially designed a form with spaces so that I could fill in the details later. I then designed some simple INPUT routines so that the computer would fill in the details for me.

If you LOAD and LIST the program, you can see how I controlled the printer. Most printer manuals have details of how to achieve the various effects but these consist of expressions such as <ESC> and "l", for example. The format in BBC BASIC is that each command is preceded by VDU. <ESC> represents 27 and any other character enclosed by < > should be interpreted literally in this way. So <BEL> is VDU 7. A full list of all the VDU codes with their names which will be used is in your computer manual. Characters enclosed by " " should have their ASCII value used so "l" will equal 49. The quickest way to find an ASCII value is to type in ASC"l" (RETURN). This will print 49 on the screen.

One more point which is very important. Every character sent to the printer should be preceded by a 1. So if the printer for example says that to select slash zero the command is:

      < ESC >  "  "  < 1 > 
you will need to enter:
      VDU 1,27,1,126,1,1
The idea of using BASIC to design and print a form seems quite a good one. If anyone would like to improve this one I would be grateful.

Some of the improvements I have in mind include:

  • Being able to alter an input after pressing RETURN
  • Being able to use a comma in a text INPUT routine. When entering addresses no commas can be used
  • Having the format of the printed layout controlled so that I can, for example, avoid words split at the end of a line and have a word starting on a new line. For example:

              25 Bertie Road South 
              sea Hampshire PO4 8J
              X
    
    If you are looking at this text in 40 column mode, the above problem may not look as bad as it is intended.
  • Being able to SAVE the DATA which has been input so that copies can be reprinted later without having to laboriously re-enter all the details. This page is actually only 1/6 of the total form and the number of details which need to be entered total over a hundred each time.

I haven't had a chance to try the INPUT routines which are included in this EUG but these may be useful.

Gus Donnachaidh, EUG #30

Gus Donnachaidh