WINPRINT-SET-JOB

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.

Usage

CALL "WIN$PRINTER" 
    USING WINPRINT-SET-JOB JOB-ID
    GIVING PRINT-JOB.

Return Values

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

Description

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:

  • The status of a printer cannot be determined using WINPRINT-GET-PRINTER-STATUS or WINPRINT-GET-JOB-STATUS unless the print job has already started. This is because the port monitor must both detect a print error and report it to the printer queue before it can be recognized by WIN$PRINTER functions.
  • Due to a limitation in the Microsoft Windows API, computers that run Windows 9x (Windows 98, and Windows ME) do not return the spooler job ID when opening a print job. This means that you cannot use the WINPRINT-GET-JOB-STATUS and WINPRINT-SET-JOB-STATUS operations of the WIN$PRINTER library routine on these machines. (These operations are used to check and modify the status of a particular printer.)

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.