There are several solutions: 1) The simple short term solution is to use a NET USE command to associate LPT1 with a network printer, such as: net use lpt1 \\usauv-print01\usaup-rndprinter The major problem with this solution is that it communicates directly with the printer, bypassing Windows print spooling. 2) In order to use the print spooler with VisualCOBOL, there are two, possibly three, solutions. One requires that the standard COBOL I/O verbs be replaced with calls to a set of standard COBOL subprograms. For example, the following sequence: OPEN OUTPUT PRINTCAL. WRITE PRINTF-R FROM TEST-RECORD. CLOSE PRINTCAL. Would be replaced with: * OPEN OUTPUT PRINTCAL. CALL "PC_PRINTER_OPEN" USING PRINT-HANDLE, DOCUMENT-TITLE, by value 4, by value 0 RETURNING STATUS-CODE. * WRITE PRINTF-R FROM TEST-RECORD. CALL "PC_PRINTER_WRITE" USING PRINT-HANDLE, TEST-RECORD, by value 23 RETURNING STATUS-CODE. * CLOSE PRINTCAL. CALL "PC_PRINTER_CLOSE" USING PRINT-HANDLE. The only troubling part about this solution is that the length of the record must be passed to the PC_PRINTER_WRITE routine. We probably already know this for fixed length records, but variable length ones will be more difficult. 3) Another solution is to use the printer_redirection tunable. To do this, we would need to create a configuration file with the following contents: set printer_redirection=TRUE Then an environment variable needs to be set to indicate that this configuration file is to be read at start up: Set COBCONFIG_= C:\Dev\KenlygenTests\TestPrinter22\TestPrinter22\print.cfg The documentation says that this will work in both native and managed code, although setting the COBCONFIG_ environment variable will not be necessary using managed code. 4) Finally, the documentation on printer_redirection states that the COBOL callable subprogram PC_PRINTER_REDIRECTION_PROC can be used to change the printer redirection to the spooler, but I have not attempted to verify this.
↧