How to print from Clipper DOS to any Windows printerIntroductionThis article talks about the Clipper programming language, but applies also to other xBase variants (like dBase for example), and covers different topics about how to correctly manage Windows printing:
Clipper printing DOS Clipper programs by default were designed to print a data flow (a sequence of characters) directly to the PRN device, which is the LPT1: parallel port. In the age of DOS, typically a dot-matrix printer was connected to LPT1:, starting printing that data as soon as it was sent to the port and before all the data has been sent by the program, but on recent Windows systems this may cause a common problem: The DOS print job starts after a long time or only when closing the Clipper program. If that happens to you too, then it's because your Clipper program does not close the printer port at the print job end. Fortunately, the Clipper language already provides a solution for this problem:
SET DEVICE TO PRINT
On some Windows systems, a single SET PRINTER TO at the print job end is not sufficient to definitely solve the problem. In this case you may also insert a call the function below, after the last SET PRINTER TO. FUNCTION Close-PRN() Local cPort := set(24,"LPT3") // Current DOS port set(24,"LPT2") set(24,"LPT1") set(24,"" ) set(24,cPort,.t.) Return Nil So far you've solved one of your problems, but you still need a DOS compatible printer connected to the port specified in the 4th line of the top sample. Clipper cannot directly address USB, DOT4 and other Windows ports which were not available in the age of DOS, so you cannot insert them in the 4th line. In addition, more and more printers nowadays are GDI (also known as Windows-Only or host-based printers), which cannot be driven by a DOS program neither if they are connected to LPT1: or if you forward the LPT1: output to one of the ports above with a simple redirection utility like the NET USE Windows command. These aspects are covered in detail in the article: How to print from DOS to USB Windows-Only printers. So, you need a Windows program like Printfil to capture the Clipper (DOS) print job, convert it into a GDI (Windows) job, THEN forward it to one of the above printers. Printfil can be configured to capture the LPT output itself, but as a programmer you may want to change the sample source above as follows: SET DEVICE TO PRINT
Other articles and videos about DOS printing in Windows |
|||||
31 May 2024 |