home *** CD-ROM | disk | FTP | other *** search
- /*
- ModHPLJD - Modify HP_LaserJet Driver
- Version 1.01 - September 1992
- Copyright © Michael Tanzer 1992
-
- +-------------------------------------------------------------------------+
- | N O T I C E |
- | |
- | Freely distributable. Not to be used for commercial purposes without |
- | written consent from the author. Not to be distributed without this |
- | notice and copyright information intact. Not be distributed with any |
- | modification to the contents of this file excluding preparation for |
- | distribution (such as packing). |
- | |
- | This product is distributed on an 'as-is' basis, with no warranty of |
- | any kind, either express or implied. No responsibility whatsoever is |
- | assumed by the author for the use of this product, nor for any results |
- | of its use. No claim whatsoever is made as to this product's accuracy, |
- | usefulness, completeness, nor suitability to any purpose. |
- | |
- | The author can be reached by telephone at +61 3 387 6589, |
- | by facsimile at +61 3 388 1863, |
- | or by post at P.O. Box 289 |
- | Carlton North VIC 3054 |
- | Australia |
- | |
- +-------------------------------------------------------------------------+
-
- Note: This is a heavily-documented Rexx program. Be careful not to
- modify it unless you have read it thoroughly and understand it.
- It was tested under Workbench 2.04 using the version of the
- HP_LaserJet driver that was packaged with that release.
-
-
- Well, you've bought yourself a Hewlett Packard LaserJet printer, hooked
- it up to your trusty Amiga and created some great-looking output with a
- desk-top publishing program or some other graphic-dumping software, and
- you're happy with your new purchase. Then you crank up the old word
- processor to see what those internal fonts will do for your correspon-
- dence. You select CG Times from the printer menu and print off a page
- of text. You go to admire your work and what do you find? Courier!
- Very nice looking Courier, but if you wanted Courier, you wouldn't have
- thrown out that clunky old typewriter. You check the printer menu
- again - yes, you did select Times, and you know you saved the choice.
- You do an 07 RESET and check the menu again just to make sure - yes,
- there it is, Times. You try printing the page again and this time it
- comes out in Times. What's going on here? After a lot of stuffing
- around, you discover that every time you boot your machine, the first
- thing you print with your word processor comes out in Courier; after
- the first page you can reset the printer and get Times from then on.
-
- Here's your problem: the HP_LaserJet printer driver you're using sends
- an 'initialise' string to the printer in front of your first line of
- text every time it's loaded, i.e. after every boot-up and after any
- other printer driver has been in use. This init string tells the prin-
- ter to use (you guessed it) Courier - 12 point, 10 pitch Courier.
-
- What can you do? Every time you want to use your word processor, you
- can print off some garbage page just to get the init out of the way,
- then reset the printer and start using Times. What a waste of time,
- toner and paper!
-
- And another thing: every once in a while, you want to use a large type-
- face, 24 points for example. If you print at six lines per inch, the
- characters in one line overlap those in the next. And the only other
- option is using eight lines per inch, which would cause even worse over-
- lapping.
-
- Fortunately, there is a solution! You can create a modified version
- of the HP_LaserJet driver which contains an init string that doesn't
- override the selections you have made on the printer menu, and allows
- you to specify fewer lines per inch. How can you accomplish this? One
- way is to get the code for the driver, learn some PCL, change the init
- string and re-compile the driver. Sounds like a lot of work, doesn't
- it? Another way is to get a good hex editor, learn some PCL, find the
- init string in the driver, change it and store the modified driver.
- Still sounds like a lot of work. How about this: read the rest of this
- file, make a simple choice as instructed and type RX MODHPLJD from the
- shell. Isn't that better? Even a Commodore rep could do it!
-
- By the way, you can use this routine even if you prefer Univers, Line
- Printer, or Courier. In fact, you can use any internal font you like.
- I would suggest that you stick to upright, medium fonts because you
- can usually select boldface and italics from your word processor.
-
- All right, let's get started. We'll begin by deciding how many lines
- per inch we want. We'll set the Rexx variable 'lpi' to indicate our
- choice. I generally use 6 lpi myself, so I have set 'lpi' to '6'. If
- you use a 24 point font, you would probably want to set this variable
- to '3'. Note that there are some limitations; you must choose a value
- from the following list: 1 2 3 4 6 8. I don't think this is too severe
- a restriction.
- */
-
- lpi = '6' /* Lines per inch: 1 2 3 4 6 or 8 */
-
- /*
- The next two variables specify the name of the existing driver and the
- the name of the driver we are creating. My own preference is to create
- the name of the new driver by adding the number of lines per inch (from
- the previous paragraph) to the name of the old driver. That is, since
- we are using HP_LaserJet as input, I have set the 'outfile' variable so
- that the new driver will be called 'HP_LaserJet_6lpi'. This way I can
- easily identify the drivers I have created and what their respective
- characteristics are. If you have a better idea, feel free to use it.
- */
-
- infile = 'HP_LaserJet' /* Name of the old driver */
- outfile = infile'_'lpi'lpi' /* Name of the new driver */
-
- /*
- If you are running under WorkBench 2.04 with the WB2.04 version of the
- HP_LaserJet driver, you are ready to run this routine. If not, you
- might like to read on so that if this routine doesn't work properly for
- you, you will have some idea about how it might be fixed. Assuming you
- are ready to proceed, here is what to do next:
-
- Make sure that this file is in the directory to which REXX: has been
- assigned. Then open a shell and type RX MODHPLJD. The result will be
- a new driver in your DEVS:printers directory. If you have not changed
- this file, the name of the new driver will be HP_LaserJet_6lpi. Open
- the Prefs drawer from the WorkBench, double-click the Printer icon, and
- click on the new name. Then click on either Save or Use, depending on
- how confident you feel. You can always go back to the old driver.
-
- Now you should be able to turn on your printer and print something. If
- this routine has worked properly, you will get output in whatever font
- you chose from the printer menu at your choice of lines per inch.
-
- This is the end of the narration. The rest of this file contains the
- Rexx code necessary to perform the actual modification of the driver.
- */
-
-
-
-
- /* Define the old init string */
- oldinit = '1b266440'x ||, /* Disable underline */
- '1b266c3644'x ||, /* 6 lines per inch */
- '1b28733062'x ||, /* Medium weight */
- '313068'x ||, /* 10 characters per inch */
- '3171'x ||, /* (see note below) */
- '3070'x ||, /* Fixed spacing */
- '3073'x ||, /* Upright style */
- '3374'x ||, /* Courier */
- '3075'x ||, /* (see note below) */
- '313256'x /* 12 point */
-
- /* Define the new init string; must be same length as old init string */
- newinit = '1b45'x ||, /* Reset */
- '1b266440'x ||, /* Disable underline */
- '1b266c'x||lpi||'44'x ||, /* 'lpi' lines per inch */
- '1b28733171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3171'x ||, /* (see note below) */
- '3055'x /* (see note below) */
-
- /*
- Note: The commands '1b28733151'x and '1b28733055'x are not documented in
- the HP LaserJet IIIP Printer User's Manual. I have included them in the
- newinit string (in combined form) in case they serve some valuable function
- under circumstances that I am unable to duplicate, and because they serve
- to pad out the length of the string to the 30 bytes required by the driver.
- If you know the purpose of these commands, I would like to hear from you.
- */
-
- /* Do the bizzo */
- call pragma('D','DEVS:printers') /* Change to printers directory */
- call open 'input',infile,'R' /* Open the old driver as input */
- if ~result then do /* Handle error */
- say 'Unable to open' infile 'for input.'
- exit 99
- end
- call open 'output',outfile,'W' /* Open the output file */
- if ~result then do /* Handle error */
- say 'Unable to open' outfile 'for output.'
- exit 98
- end
- driver = readch('input',65535) /* Read the driver */
- length = length(driver) /* Save the length */
- disp = pos(oldinit,driver) /* Displacement to init string */
- if disp=0 then do /* Handle init string not found */
- say 'Unable to locate init string in' infile'.'
- exit 97
- end
- driver = overlay(newinit,driver,disp) /* Replace init string */
- call writech('output',driver) /* Write the new driver */
- if result~=length then do /* Handle error */
- say 'Error writing' outfile 'to disk.'
- exit 96
- end
- call close 'input' /* Close input file */
- call close 'output' /* Close output file */
- say outfile 'created.' /* Type the good news */
- exit /* ...and to all a good night! */
-