This operation code returns the identifier of the job that is currently spooling into the printer. The ID number returned by this operation will be compatible with, and may be used in conjunction with, the operations WINPRINT-SET-JOB-STATUS and WINPRINT-GET-JOB-STATUS.
CALL "WIN$PRINTER" USING WINPRINT-SET-JOB JOB-ID GIVING PRINT-JOB.
If you set JOB-ID to 0, WINPRINT-SET-JOB returns the identifier of the job that is currently spooling into the printer (PRINT-JOB). You can then use that number to tell WIN$PRINTER operations which print job is the target. This is your only way to obtain the ID of a job. To restore the system default settings, simply call this operation with a JOB-ID of -1
This call should be issued immediately after the opening of a job. For example:
OPEN OUTPUT FIRST-FILE. CALL "WIN$PRINTER" USING WINPRINT-SET-JOB JOB-ID GIVING FIRST-ID.
where FIRST-ID is a variable declared signed-integer, such as:
77 FIRST-ID USAGE SIGNED-INT.
Subsequent calls to WIN$PRINTER may use FIRST-ID to identify the target for the next action, as follows:
OPEN OUTPUT FIRST-FILE. CALL "WIN$PRINTER" USING WINPRINT-SET-JOB 0 GIVING FIRST-ID. OPEN OUTPUT SECOND-FILE. | Is now current. *Initialize the print record for the first print job. MOVE "This is job 1, printed with MS Sans Serif." TO RECORD-FILE-1. *Initialize the print record for the second print job. MOVE "This is job 2, printed with Script." TO RECORD-FILE-2. *Set active job to the first print job. CALL "WIN$PRINTER" USING WINPRINT-SET-JOB FIRST-ID. *Set the preferred font for the first print job. INITIALIZE WINPRINT-DATA. MOVE FIRST-FONT TO WPRTDATA-FONT. CALL "WIN$PRINTER" USING WINPRINT-SET-FONT WINPRINT-DATA.
If you try to perform an operation that requires an active print job and there is none, an error status is returned. This series of calls can be used with all WIN$PRINTER functions, with the following exceptions:
When you are printing multiple jobs simultaneously, you should not set a printer font before the print job has been opened because the font could be applied to the wrong job. Once the print job is opened, you may set the font, using the JOB-ID of the target printer.
However, if you need to change the printer settings for subsequent job on a different printer, you should set JOB-ID to -1 before setting WINPRINT-SET-SETTINGS or WINPRINT-SET-PRINTER(-EX). This causes WINPRINT-SET-JOB to return the ID number of the next job in the queue (after the current job). This should be done just prior to calling an OPEN statement. When JOB-ID is set to -1, the runtime executes the next WIN$PRINTER operation as if no current job were printing. This does not affect existing jobs, but it affects the status of subsequent jobs, unless it is an OPEN, WRITE, or CLOSE statement.