Printing - Executing multiple Windows print jobs simultaneously

0 Likes

Problem:

At times it is desirable to execute more than one print job at a time.

Resolution:

Getting Started with ACUCOBOL-GT

Version 8.0

Chapter 2: Windows Installation > 2.5 Printing and Spooler Issues >

2.5.3 Printing Multiple Jobs Simultaneously

If it is desirable to print multiple jobs at the same time, multiple File Descriptors must be opened that point to "-P SPOOLER" or "-P SPOOLER-DIRECT" simultaneously. For example, there may be two simultaneous print jobs:

SELECT FIRST-FILE

       ASSIGN TO PRINTER "-P SPOOLER".

SELECT SECOND-FILE

       ASSIGN TO PRINTER "-P SPOOLER".

..PROCEDURE DIVISION.

..

       OPEN OUTPUT FIRST-FILE.

       OPEN OUTPUT SECOND-FILE.

and both will print to the default Windows printer without interfering with each other. A call can be made to WIN$PRINTER USING WINPRINT-SETUP before one or both of the OPEN statements. Each file may have individual file status variables, or may refer to a common file status variable.

This does not mean that a single File Descriptor can be opened multiple times. For example, the following will return file status indicating that the file is already opened:

SELECT FIRST-FILE

       ASSIGN TO PRINTER "-P SPOOLER".

..

PROCEDURE DIVISION.

..

       OPEN OUTPUT FIRST-FILE.

       OPEN OUTPUT FIRST-FILE.

This is normal behavior and is consistent with the way file handling is implemented in COBOL and in other programming languages.

If the program code is using only the verbs OPEN, CLOSE and WRITE, no further changes to the code is needed. If the program code is using WIN$PRINTER functionality (other than WINPRINT-SETUP) it will need to specify which print job is affected. This can be done in two ways:

1.  The simplest way is to execute the WIN$PRINT operation immediately after an OPEN or WRITE statement on the intended job. Every execution of OPEN and WRITE sets the current job as the default so that subsequent activity using WIN$PRINTER is automatically directed to the job that was last accessed with an OPEN or WRITE statement.

In this situation, if multiple jobs are running, and one of them is chosen, the runtime switches to the next job in the list. For example, if jobs 1, 2 and 3 are printing  and job 2 is closed, the close command sets the current job to 3. If there is no job 3, the runtime attempts to set to the job that preceded the closed job (which in this case is job 1). If there are no jobs, the current job is initialized.

2.  The other method is to use the WINPRINT-SET-JOB operation of the WIN$PRINTER library routine. This operation is described in Appendix I of the ACUCOBOL-GT manual set.

Old KB# 2674
Comment List
Related
Recommended