Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
aw_muench Respected Contributor.
Respected Contributor.
1279 views

Printer tray names

We want to show the possible printer tray names and try to use DeviceCapabilities from winspool.drv.

If I enter the  debugger and step over the DeviceCapabilities-call it works perfectly - again and again as long as I stay in the program.

If the call is executed without entering the debugger I get a "memory access violation".

Here is the code:

       01            WK-WINSPOOLDRVJN  PIC X(01).

       01            WK-TRAYTABELLE.
           02        WK-TRAYSATZ       OCCURS MAX-PAPER-TRAYS.
            03       WK-TRAYNAME       PIC X(24).

       01            WINSPOOL-PRINTER  PIC X(80).
       01            WINSPOOL-PORT     PIC X(80).
       01            WINSPOOL-FC       PIC 9(4) COMP-5.

=================================================================       
           MOVE "J"                    TO WK-WINSPOOLDRVJN.

           CALL "c:\Windows\System32\winspool.drv"
           ON EXCEPTION
                MOVE "N"               TO WK-WINSPOOLDRVJN
                GO TO PCPDRU10MEDIA-WINPRINT
           END-CALL.

           MOVE WRAL50-COMBOZEILE      TO WINSPOOL-PRINTER.
           INSPECT WINSPOOL-PRINTER    REPLACING TRAILING SPACES
                                       BY X"00".

           MOVE WINPRINT-PORT          TO WINSPOOL-PORT.
           INSPECT WINSPOOL-PORT       REPLACING TRAILING SPACES
                                       BY X"00".
                                       
           MOVE SPACE                  TO WK-TRAYTABELLE.
           MOVE 12                     TO WINSPOOL-FC.

           CALL "DeviceCapabilitiesA"  USING
                BY REFERENCE  WINSPOOL-PRINTER
                BY REFERENCE  WINSPOOL-PORT
                BY VALUE      WINSPOOL-FC
                BY REFERENCE  WK-TRAYTABELLE
           ON EXCEPTION
                MOVE "N"               TO WK-WINSPOOLDRVJN
                GO TO PCPDRU10MEDIA-WINPRINT
           END-CALL.

           IF   WK-TRAYTABELLE         = SPACE
                MOVE "N"               TO WK-WINSPOOLDRVJN.

Do you see my error or do you have a tip for me ?

              
Thanks in advance for your support.

Andreas

0 Likes
3 Replies
Micro Focus Expert
Micro Focus Expert

RE: Printer tray names

Have you seen our prndemox.cbl example? the source-lines in PRNDEMOX.cbl use WINPRINT-GET-PRINTER-MEDIA to search for the paper-trays.

0 Likes
Chuck Edgin Absent Member.
Absent Member.

RE: Printer tray names

How do you have MAX-PAPER-TRAYS defined, and what is the value? I tried your code and it worked well, but if I set MAX-PAPER-TRAYS to a number lower than the actual number of trays defined, the call to "DeviceCapabilitiesA" caused some memory corruption. I presume this is because this makes the WK-TRAYTABELLE table too small, so DeviceCapabilitesA attempts to write too much data to it and causes an overflow.

0 Likes
aw_muench Respected Contributor.
Respected Contributor.

RE: Printer tray names

Hi Chuck,

thanks for your quick reply.

I tried to use MAX-PAPER-TRAYS from the copybook WINPRINT.DEF

WINPRINT.DEF:       78  MAX-PAPER-TRAYS                     VALUE 13.

Or what do you think could be a reasonable number ?

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.