Highlighted
Absent Member.
Absent Member.
1774 views

How do you print directly under windows 7 platform using Visual Studio 2010 COBOL and USB PRINTER?

Jump to solution

[Migrated content. Thread originally posted on 28 March 2012]

I need to be able to print directly to a printer so that a test page can be sent out and redone until the print is aligned. This works under Micro Focus COBOL (Unix) by the file-id being '/dev/lp1' or /dev/lp0/ where these were parallel printers but now we are moving to Windows 7 and all of the new printers are USB. There is also a restart in the program so that all of the pages printed correctly do not have to be reprinted.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How do you print directly under windows 7 platform using Visual Studio 2010 COBOL and USB PRINTER?

Jump to solution
There are a couple ways to do this under Windows.

Do the following:

1. Create a textfile called cobconfig.cfg and add the following line to it:

set printer_redirection=TRUE

2. set the environment variable COBCONFIG=c:\myfolder\cobconfig.cfg replacing c:\myfolder\ with the actual location of cobconfig.cfg on your system.

3. In your program code the printer file as:

select print-file assign to printer
organization is line sequential.

4. Now when the file is open all output will be redirected to the print spooler for your default printer.

5. If you need to change the default printer for your program then you should call the library routine PC_PRINTER_SET_DEFAULT.

See the entire list of Printer library routines in the documentation:

Another alternative is to write the file to disk and then send it to the printer using PC_PRINT_FILE.

Thanks.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How do you print directly under windows 7 platform using Visual Studio 2010 COBOL and USB PRINTER?

Jump to solution
There are a couple ways to do this under Windows.

Do the following:

1. Create a textfile called cobconfig.cfg and add the following line to it:

set printer_redirection=TRUE

2. set the environment variable COBCONFIG=c:\myfolder\cobconfig.cfg replacing c:\myfolder\ with the actual location of cobconfig.cfg on your system.

3. In your program code the printer file as:

select print-file assign to printer
organization is line sequential.

4. Now when the file is open all output will be redirected to the print spooler for your default printer.

5. If you need to change the default printer for your program then you should call the library routine PC_PRINTER_SET_DEFAULT.

See the entire list of Printer library routines in the documentation:

Another alternative is to write the file to disk and then send it to the printer using PC_PRINT_FILE.

Thanks.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.