Configuring a Printer for dL4 for Windows
First you must decide whether to use direct or piped output to the printer. In dL4 for Unix and pre-3.1 versions of dL4 for Windows, printer output is performed by sending the output to a separately executed program, a printer script. A printer script typically executes a few commands and then invokes the pfilter utility to copy and translate characters to the printer. In versions 3.1 and later of dL4 for Windows, the copy and translation function can be performed by the pipe driver itself. This direct printing is the preferred method because it is easier to configure and more robust. A script should be used only if external commands are needed to setup the printer. If you need to use a script, go to section II, ?Configuring a printer script?, otherwise continue with step 1 of ?Configuring for direct print?.
I. Configuring for direct print
1. Create your printer definition file (printer.def). The example shown below is a good starting place. Other examples and more information can be found in the "dL4 Installation & Configuration Guide for Windows 95/NT". The printer definition file below is a working, minimal definition that will output the default character set for your printer.
[Macros]
; Variable usage
; X current column
; a = Increment column counter
; c = Add pop() to column counter
; e = Clear column counter
a=%GX%{1}%+%SX
c=%GX%+%SX
e=%{0}%SX
; m = Max function = push(pop() max pop())
m=%Sx%Sy%?%Gx%Gy%<%t%Gy%e%Gx%;
[OutputMacros]
; Output linefeed as is
'LF'=^J
; Zero column counter when printing a formfeed
'FF'=^L%Me
; Print carriage return with a following linefeed and zero the
column counter
'CR','NEL','LINESEP'=^M^J%Me
; If carriage return doesn't need to be followed by a linefeed,
change the preceding
; line to 'CR','NEL','LINESEP'=^M%Me
; Define all other characters to increment the column counter
Default=%@%c%Ma
; Define horizontal position (TAB) and alignment (PRINT comma)
mnemonics
@#=%p1%GX%Mm%Sx%Gx%GX%-%r\s%;%Gx%SX
'#ALIGN'=%p1%GX%p1%m%-%Sx%Gx%r\s%;%Gx%Mc
[OutputUnicodeMapping]
; This mapping is set up for 8-bit output on a printer using
; the ISO 8859-1 (i.e. ANSI Latin 1) character set.
Set0=
0x0000-0x00ff=0x00
2. Create the printer batch file (dl4lpt.bat). This must be a text file containing text similar to this:
rem dL4opts=output=\\server\printer,translate=c:\dl4\printers\printer.def
-- OR --
rem dL4opts=output=lpt1,translate=c:\dl4\printers\printer.def
Replace "\\server\printer" or ?lpt1? with the path or name of your printer.
NOTE: A printer batch file cannot have the same name as a MS-DOS device such as CON, NUL, LPT1 and PRN. If you need to use such a reserved name, use the LUMAP (dL4 3.1 or later) runtime parameter to translate the name to a legal filename. The extension of the file must be ".BAT". The batch file must be in a directory specified in the PATH environment variable.
3. Test the batch file using a small BASIC program. The following will work for most purposes:
10 Open #1,"$dl4lpt.bat" ! note that ".bat" is not required
20 Print #1;"First line"
30 Print #1;?Second line?
40 Close #1
50 End
4. Retest the batch file from a different directory, using the Step 3 BASIC program, to make sure your PATH environment variable is set correctly. The batch file must be in a directory specified in the PATH environment variable.
5. If you are using a non-spooled printer, the lock option should be used to prevent more than one user from opening the printer at one time. In this case, add ",lock=true" to the end of the "rem dl4opts" line as shown below:
rem dL4opts=output=lpt1,translate=c:\dl4\printers\printer.def,lock=true
6. Done.
II. Configuring a printer script
1. To configure a printer using a printer script, first create your printer definition file (printer.def). A good starting place for a first time test is the printer definition from "dL4 Installation & Configuration Guide for Windows 95/NT". The printer definition file below is a working, minimal definition that will output the default character set for your printer.
[OutputMacros]
Default=%@%c
[OutputUnicodeMapping]
; This mapping is set up for 8-bit output on a printer using
; the ISO 8859-1 (i.e. ANSI Latin 1) character set.
Set0=
0x0000-0x00ff=0x00
2. Test the printer definition from the MS-DOS prompt:
a) create a temporary test file:
copy con: testfile
test^Z
b) This command will copy your printer definition to the file "testfile" through the pfilter utility. You will be able to do a file compare (fc) between the two files to check the results. If there are any errors, pfilter will show them on the screen. On a single line, type:
type c:\dl4\printers\printer.def | c:\dl4\pfilter c:\dl4\printers\printer.def -d testfile
3. Check the printer attachment to MS-DOS / Windows from the MS-DOS prompt: This command will copy your printer definition file to the printer device through the pfilter utility. If there are any errors, pfilter will show those errors on the screen. On a single line, type:
type c:\dl4\printers\printer.def | c:\dl4\pfilter c:\dl4\printers\printer.def
-d \\server\printer
-- OR --
type c:\dl4\printers\printer.def | c:\dl4\pfilter c:\dl4\printers\printer.def
-d lpt1:
4. Create the printer batch file (dl4lpt.bat). Create this file as a single line file from the previous step. The data in the file is the command after the pipe (|) symbol.
c:\dl4\pfilter c:\dl4\printers\printer.def -d \\server\printer
-- OR --
c:\dl4\pfilter c:\dl4\printers\printer.def -d lpt1:
NOTE: A printer batch file cannot have the same name as a MS-DOS device such as CON, NUL, LPT1 and PRN. If you need to use such a reserved name, use the LUMAP (dL4 3.1 or later) runtime parameter to translate the name to a legal filename. The extension of the file must be ".BAT". The batch file must be in a directory specified in the PATH environment variable.
5. Test the batch file using a small BASIC program. The following will work for most purposes:
10 Open #1,"$dl4lpt.bat" ! note that ".bat" is not required
20 Print #1;"First line"
30 Print #1;?Second line?
40 Close #1
50 End
6. Retest the batch file from a different directory, using the Step 5 BASIC program, to make sure your PATH environment variable is set correctly. The batch file must be in a directory specified in the PATH environment variable.
When your printer definition and batch files pass this hurdle they are ready for primary installation testing.
7. Add the printer script option for character set. The available character sets are listed in the "dL4 Installation & Configuration Guide for Windows 95/NT." Both the "REM" statement in the batch file and the pfilter line must contain the same character set. This example is using dL4's native character set, utf-8.
rem dL4opts=charset=utf-8
c:\dl4\pfilter -c utf-8 c:\dl4\printers\printer.def -d \\server\printer
-- OR --
rem dL4opts=charset=utf-8
c:\dl4\pfilter -c utf-8 c:\dl4\printers\printer.def -d lpt1:
8. If you are using a non-spooled printer, the lock option should be used to prevent more than one user from opening the printer at one time. In this case, add ",lock=true" to the end of the "rem dl4opts" line as shown below:
rem dL4opts=charset=utf-8,lock=true
9. Done.
For further documentation on printer batch files and their pipe files refer to the "dL4 Installation & Configuration Guide for Windows 95/NT."