Highlighted
Absent Member.
Absent Member.
498 views

[archive] DUPLEX printing

[Migrated content. Thread originally posted on 19 February 2009]

I have a printer that supports printing on both sides but I can't get it to work with acucobol 8.1. This is the code. Can anyone tell me what I'm doing wrong. I can set WINPRINT-CURR-COPIES but not WINPRINT-CURR-DUPLEX. TIA

INITIALIZE WINPRINT-SELECTION.
CALL "WIN$PRINTER" USING WINPRINT-SETUP.

* Get printer defaults.
CALL "WIN$PRINTER" USING WINPRINT-GET-CURRENT-INFO-EX
WINPRINT-SELECTION.

DISPLAY "WINPRINT-CURR-COPIES = " WINPRINT-CURR-COPIES
DISPLAY "WINPRINT-CURR-DUPLEX = " WINPRINT-CURR-DUPLEX.


MOVE 2 TO WINPRINT-CURR-COPIES.
MOVE 3 TO WINPRINT-CURR-DUPLEX.

* Set the printer # of copies
INITIALIZE WINPRINT-CURR-COLLATE.
CALL "WIN$PRINTER" USING WINPRINT-SET-PRINTER-EX
WINPRINT-SELECTION.


* Get printer defaults.
CALL "WIN$PRINTER" USING WINPRINT-GET-CURRENT-INFO-EX
WINPRINT-SELECTION.

DISPLAY "WINPRINT-CURR-COPIES = " WINPRINT-CURR-COPIES
DISPLAY "WINPRINT-CURR-DUPLEX = " WINPRINT-CURR-DUPLEX.
0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

If you can provide a small example program here, I can have a look at it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

Thank you, I appreciate that.


IDENTIFICATION DIVISION.
PROGRAM-ID. TestPrint.
*
* Print any source file.
*

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.

INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT SOURCE-FILE ASSIGN TO WS-SOURCE-NAME
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS WS-FILE-STATUS.

SELECT PRINT-FILE
ASSIGN PRINT WS-PRINTER-NAME
ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SOURCE-FILE.
01 SOURCE-FILE-REC.
03 SOURCE-FILE-CHAR PIC X OCCURS 132.

FD PRINT-FILE.
01 PRINT-FILE-REC PIC X(132).


$PAGE
WORKING-STORAGE SECTION.
COPY "ACUGUI.DEF".
COPY "WINPRINT.DEF".
COPY "FONTS.DEF".

01 WS-FILE-STATUS PIC 99.
88 SUCCESSFUL VALUE 00.

01 WS-SOURCE-NAME PIC X(60).
01 WS-SOURCE-LOC PIC X(40)
VALUE "..\SOURCE\".
01 WS-SOURCE-LOC-NEW PIC X(40) VALUE SPACES.
01 WS-SOURCE-FILE PIC X(20).


01 WS-FONT-HANDLE USAGE HANDLE OF FONT.
01 WS-PRINTER-FONT-RESULT PIC S9(4).
01 WS-FONT-SIZE PIC ZZ9.
01 WS-PRINTER-NAME PIC X(30) VALUE "-P SPOOLER".

01 WS-LINE-NO PIC 99 VALUE 0.
01 WS-PAGE-NO PIC 9(9) VALUE 0.
01 WS-HEADING.
03 FILLER PIC X(7) VALUE SPACES.
03 FILLER PIC X(11) VALUE "WINPRINT:".
03 H1-FILE-NAME PIC X(60).
03 FILLER PIC X(10) VALUE SPACES.
03 FILLER PIC X(6) VALUE "PAGE:".
03 H1-PAGE-NO PIC ZZZ9.


$PAGE
PROCEDURE DIVISION.
DECLARATIVES.
ERROR-PROCESSING SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON INPUT.
OUTPUT-FILE-ERROR.
* Leave this area empty and check after all file access
END DECLARATIVES.


A-MAIN SECTION.
A010.
PERFORM B-INIT.

A020-OPEN-FILES.
OPEN OUTPUT PRINT-FILE.
OPEN INPUT SOURCE-FILE.


A030-READ-FILE.
MOVE SPACES TO SOURCE-FILE-REC.
READ SOURCE-FILE AT END GO TO A039-END-OF-FILE.

PERFORM D-CHECK-FOR-NEW-PAGE.

A036-PRINT.
MOVE SOURCE-FILE-REC TO PRINT-FILE-REC.
WRITE PRINT-FILE-REC BEFORE 1.
ADD 1 TO WS-LINE-NO.

GO TO A030-READ-FILE.

A039-END-OF-FILE.


A090-CLOSE-FILES.
CLOSE PRINT-FILE.
CLOSE SOURCE-FILE.
STOP RUN.

$PAGE
B-INIT SECTION.
B010.
DISPLAY WINDOW
COLOR 1168.

B020-SOURCE-FILE.
DISPLAY "Enter a source file (name & extension): "
NO ADVANCING.
ACCEPT WS-SOURCE-FILE.
IF WS-SOURCE-FILE = SPACES
STOP RUN.

DISPLAY " ".
DISPLAY "Source files are assumed to be in: " WS-SOURCE-LOC.
DISPLAY "You may enter an alternate loc: " NO ADVANCING.
ACCEPT WS-SOURCE-LOC-NEW.
IF WS-SOURCE-LOC-NEW > SPACES
MOVE WS-SOURCE-LOC-NEW TO WS-SOURCE-LOC.
DISPLAY "Location to be used for Source: " WS-SOURCE-LOC.

MOVE SPACES TO WS-SOURCE-NAME.
STRING WS-SOURCE-LOC
WS-SOURCE-FILE
DELIMITED BY " "
INTO WS-SOURCE-NAME.
MOVE WS-SOURCE-NAME TO H1-FILE-NAME.


B050-INIT-PRINTER.
INITIALIZE WINPRINT-SELECTION.
CALL "WIN$PRINTER" USING WINPRINT-SETUP.

* Get printer defaults.
CALL "WIN$PRINTER" USING WINPRINT-GET-CURRENT-INFO-EX
WINPRINT-SELECTION.

DISPLAY "BEFORE SETPRINTER".
DISPLAY "WINPRINT-CURR-COPIES = " WINPRINT-CURR-COPIES
DISPLAY "WINPRINT-CURR-DUPLEX = " WINPRINT-CURR-DUPLEX.


MOVE 2 TO WINPRINT-CURR-COPIES.
MOVE 2 TO WINPRINT-DUPLEX.
MOVE 3 TO WINPRINT-CURR-DUPLEX.

* Set the printer copies & duplex
INITIALIZE WINPRINT-CURR-COLLATE.
CALL "WIN$PRINTER" USING WINPRINT-SET-PRINTER-EX
WINPRINT-SELECTION.


* Get printer defaults.
CALL "WIN$PRINTER" USING WINPRINT-GET-CURRENT-INFO-EX
WINPRINT-SELECTION.

DISPLAY "AFTER SETPRINTER".
DISPLAY "WINPRINT-CURR-COPIES = " WINPRINT-CURR-COPIES
DISPLAY "WINPRINT-CURR-DUPLEX = " WINPRINT-CURR-DUPLEX.

DISPLAY "PRESS ANY KEY ".
ACCEPT OMITTED.


* Set the font and size
INITIALIZE WFONT-DATA.
SET WFDEVICE-WIN-PRINTER TO TRUE.
SET WFCHARSET-DEFAULT TO TRUE.
* Font names are CASE SENSITIVE
MOVE "Courier New" TO WFONT-NAME.
* If the font size changes, adjust the max line/page: section D
MOVE 10 TO WFONT-SIZE, WS-FONT-SIZE.
CALL "W$FONT" USING WFONT-GET-FONT,
WS-FONT-HANDLE,
WFONT-DATA
GIVING WS-PRINTER-FONT-RESULT.
IF WS-PRINTER-FONT-RESULT <> 1
DISPLAY "Invalid font/size: " WFONT-NAME WS-FONT-SIZE.

MOVE WS-FONT-HANDLE TO WPRTDATA-FONT.
CALL "WIN$PRINTER" USING WINPRINT-SET-FONT,
WINPRINT-DATA
GIVING WS-PRINTER-FONT-RESULT.


$PAGE
D-CHECK-FOR-NEW-PAGE SECTION.
D010.
IF WS-LINE-NO > 50 OR
WS-PAGE-NO = 0
MOVE 0 TO WS-LINE-NO
ADD 1 TO WS-PAGE-NO
MOVE WS-PAGE-NO TO H1-PAGE-NO
MOVE WS-HEADING TO PRINT-FILE-REC
IF WS-PAGE-NO > 1
WRITE PRINT-FILE-REC AFTER PAGE
ELSE,
WRITE PRINT-FILE-REC
END-IF
MOVE SPACES TO PRINT-FILE-REC
WRITE PRINT-FILE-REC BEFORE 2.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

You're probably better off with an attached file
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

Thx, I will look at it at opportunity.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

Hi,
I have tried your program, sorry it took so long, but this requires a special printer you know, not all printers do duplex.
Anyways, the program worked just great. Printed on both sides, so assuming your printer really do support duplex, there must be something else. Which version are you trying this with? I tested with version 8.1.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] DUPLEX printing

Sorry for the delay, I was away last week. Yes I'm aware that not all printers support duplex. I'm using an HP4250 that prints in duplex from other applications. I'm using 8.1 as well. If you got it to work then I guess it's me - thanks for your help - I'll keep looking.
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.