skip to main content

Library Routines : WIN$PRINTER

WIN$PRINTER
The WIN$PRINTER library routine provides a number of functions to manage printers.
The WIN$PRINTER routine is not thread-safe and so it should be used carefully in multithread programs. When two print jobs are executed simultaneously by the same program, results are unpredictable.
The WIN$PRINTER functions can be divided in two groups.
1.
 
2.
The second group of functions requires an X11 display.
Syntax:
 CALL "WIN$PRINTER" USING opCode
Parameters:
Return code:
returnCode can be any signed numeric data item. The meaning depends on the opcode.
Examples:
Example - Calling win$printer with different op-codes to generate a graphical document
       program-id. winprinter.
       input-output section.
       file-control.
       select print-job assign to printer spooler-name
           organization line sequential.
       file section.
       FD  print-job.
       01  print-record            pic x(80).
       working-storage section.
       copy "isgui.def".
       copy "iscrt.def".
       copy "isopensave.def".
       copy "isprint.def".
       77  crt-status              special-names crt status pic 9(5).
       77  hWin                    handle of window.
       77  close-win               pic 9 value 0.
       77  hBmp                    pic s9(9comp-4.
       77  spooler-name            pic x(128).
       77  printer-num             pic 9(3).
       77  winprint-status         pic s99.
       screen section.
       01  Mask.
              line                 2
              col                  2
              size                 10 cells
              title                "Printers:"
           03 cb-printers
              line                 4
              col                  2
              size                 30 cells
           03 push-button
              line                 7
              col                  2
              title                "&Print"
              exception-value      101
           03 push-button
              line                  7
              col                   + 2
              title                 "Pre&view"
              exception-value       102
           03 push-button
              line                 7
              col                  + 2
              title                "PD&F"
              exception-value      103
       procedure division.
           call "w$bitmap" using wbitmap-load, "files/img.png" 
           display independent graphical window
                   title  "win$printer routine"
           perform get-printers-names
           perform until crt-status = 27 or close-win = 1
             evaluate crt-status
           call "w$bitmap" using wbitmap-destroy, hBmp
           move "-p preview" to spooler-name
           perform print-procedure
           initialize opensave-data, spooler-name.
           accept opnsav-default-dir from environment "user-path"
           move "PDF Files (*.pdf)|*.pdf" to opnsav-filters
           move "pdf"                     to opnsav-default-ext
           call "c$opensavebox" using opensave-save-box
           if return-code < 0
           string "-p pdf "       delimited by size
           perform PRINT-PROCEDURE
           move "-p spooler" to spooler-name
           initialize winprint-selection
           inquire cb-printers value winprint-name
           call "win$printer" using winprint-set-printer
           perform print-procedure
           modify cb-printers reset-list 1
           perform varying printer-num from 1 by 1 until 1 = 2
              initialize winprint-selection
              move printer-num to winprint-no-of-printers
              call "win$printer" using winprint-get-printer-info
              if winprint-status < 1
              modify cb-printers item-to-add winprint-name 
              if wprt-is-default
                  modify cb-printers value winprint-name
           open output print-job
      *print of bitmap pictures
           initialize wprtdata-print-bitmap
           move hBmp to wprtdata-bitmap
           move 3    to wprtdata-bitmap-row
           move 3    to wprtdata-bitmap-col
           move 5    to wprtdata-bitmap-height
           move 6    to wprtdata-bitmap-width 
           move wprtbitmap-scale-centimeters to wprtdata-bitmap-flags
           add  wprtbitmap-units-centimeters to wprtdata-bitmap-flags
           call "win$printer" using winprint-print-bitmap
      *print of colored strings (RGB = 96,106,232)
           initialize wprtdata-text-color.   
           compute wprtdata-text-color = (232 * 65536) +
           call "win$printer" using winprint-set-text-color   
           write print-record from "colored string"      
      *print of graphical shapes (how to create a table)
           initialize wprtdata-draw
           move 2  to wprtdata-draw-start-x
           move 10  to wprtdata-draw-start-y
           move 18 to wprtdata-draw-stop-x
           move 15 to wprtdata-draw-stop-y
           move wprtunits-centimeters to wprtdata-draw-units
           move wprt-draw-rectangle   to wprtdata-draw-shape
           call "win$printer" using winprint-graph-draw
           initialize wprtdata-draw
           move 5  to wprtdata-draw-start-x
           move 10 to wprtdata-draw-start-y
           move 5  to wprtdata-draw-stop-x
           move 15 to wprtdata-draw-stop-y
           move wprtunits-centimeters to wprtdata-draw-units
           move wprt-draw-line        to wprtdata-draw-shape
           call "win$printer" using winprint-graph-draw
           initialize wprtdata-draw
           move 2  to wprtdata-draw-start-x
           move 12 to wprtdata-draw-start-y
           move 18 to wprtdata-draw-stop-x
           move 12 to wprtdata-draw-stop-y
           move wprtunits-centimeters to wprtdata-draw-units
           move wprt-draw-line        to wprtdata-draw-shape
           call "win$printer" using winprint-graph-draw
           close print-job
           if event-type = cmd-close
              move 1 to close-win

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left