Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing in Windows 1

Status
Not open for further replies.

SteveMillman

Programmer
Jun 3, 2001
36
US
Hi,

I wrote a bunch of Microsoft COBOL 5.0 applications over 10 years ago (under MS-DOS) and hard coded Epson Printer codes into the apps to allow me to print 255 characters wide (with compression), print
80 characters wide, etc.

Now with Windows being our local operating environment(for several years) I am wondering .. if I recompiled these programs to Windows, could I possibly make use of WIndows interfaces to its printers - to have an application choose a "default printer" and even assign its format (condensed, expanded, etc.) for a given line or application?

If so I could give our users a jump start into the late 20th century ...

I'd appreciate any specific advise or referrals to sample code.

Thank you,

Steve
 
Here is an approach that I have found useful:

Write printer output to a line sequntial file first without any carriage control. Instead used blank lines to skip lines. The advantage here is that now you have a file that could be browsed. Then make a common print routine that can be called in a subsequent step. It is also easy to use the line sequential file as input to a routine to inject HTML tags. How you approach all this depends a lot on whether your reports need control breaks when printed. For instance if you just need column headings don’t use control breaks at all in the browsable version. If you use control breaks use a scheme to identify them in the print routine.

If you don’t want to make a lot of changes to existing code, just change the output from printer to file and then write a routine to zap carriage control and escape codes in the files prior to inputting to a print routine
 
Maybe this could be of some use:

IDENTIFICATION DIVISION.
PROGRAM-ID. PRINTSPL.
AUTHOR. CLIVE CUMMINS.
INSTALLATION. TUBULARITY.
DATE-WRITTEN. AUG 27,1992.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PRINT-SPOOL-FILE ASSIGN TO PRINTSPL-FILE-ID
FILE STATUS IS PRINTSPL-RETURN-CODE
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO PRINTER.
DATA DIVISION.
FILE SECTION.
FD PRINT-SPOOL-FILE.
01 PRINT-SPOOL-RECORD PIC X(132).
FD PRINT-FILE.
01 PRINT-RECORD PIC X(132).
WORKING-STORAGE SECTION.
01 PROGRAM-DETAILS.
05 PROGRAM-RELEASE.
10 PROGRAM-NAME PIC X(08) VALUE 'PRINTSPL'.
10 PROGRAM-REL PIC X(08) VALUE ' 1.0.00'.
01 HP-WORK-AREA.
05 HP-RESET PIC X(02) VALUE x"1B45".
05 HP-FONT-80 PIC X(02) VALUE x"1B45".
05 HP-FONT-96.
10 FILLER PIC X(02) VALUE x"1B28".
10 HP-SYMBOL-SET PIC X(03) VALUE "10U".
10 FILLER PIC X(02) VALUE x"1B28".
10 HP-SPACING PIC X(03) VALUE "s0p".
10 HP-PITCH PIC X(06) VALUE "12.00h".
10 HP-POINT-SIZE PIC X(05) VALUE "10.0v".
10 HP-STYLE PIC X(02) VALUE "0s".
10 HP-STROKE-WEIGHT PIC X(02) VALUE "0b".
10 HP-TYPEFACE PIC X(02) VALUE "3T".
10 FILLER PIC X(02) VALUE x"1B26".
10 HP-ORIENTATION PIC X(03) VALUE "l0O".
05 HP-FONT-132.
10 FILLER PIC X(02) VALUE x"1B28".
10 HP-SYMBOL-SET PIC X(03) VALUE "10U".
10 FILLER PIC X(02) VALUE x"1B28".
10 HP-SPACING PIC X(03) VALUE "s0p".
10 HP-PITCH PIC X(06) VALUE "16.67h".
10 HP-POINT-SIZE PIC X(04) VALUE "8.5v".
10 HP-STYLE PIC X(02) VALUE "0s".
10 HP-STROKE-WEIGHT PIC X(02) VALUE "0b".
10 HP-TYPEFACE PIC X(02) VALUE "0T".
10 FILLER PIC X(02) VALUE x"1B26".
10 HP-ORIENTATION PIC X(03) VALUE "l0O".
05 LINE-SPACING PIC 9(01) VALUE 1.
05 PRINTSPL-FILE-NAME PIC X(08) VALUE "PRINTOUT".
05 PRINTSPL-FILE-ID PIC X(12).
05 PRINTSPL-RETURN-CODE PIC X(02).
88 PRINTSPL-SUCCESSFUL VALUE "00".
88 PRINTSPL-EOF VALUE "10".
05 FIRST-TIME-SW PIC X(01) VALUE HIGH-VALUES.
88 FIRST-TIME VALUE HIGH-VALUES.
PROCEDURE DIVISION.
1000-CONTROL.
MOVE HIGH-VALUES TO FIRST-TIME-SW.
STRING PRINTSPL-FILE-NAME ".TXT" DELIMITED BY SPACE
INTO PRINTSPL-FILE-ID.
MOVE ZERO TO PRINTSPL-RETURN-CODE.
OPEN INPUT PRINT-SPOOL-FILE
OUTPUT PRINT-FILE.
IF PRINTSPL-SUCCESSFUL
PERFORM 9000-READ-SPOOL-FILE
IF PRINTSPL-SUCCESSFUL
PERFORM 2000-PRINT-RPT.
CLOSE PRINT-SPOOL-FILE
PRINT-FILE.
GOBACK.
2000-PRINT-RPT.
MOVE ZERO TO LINE-SPACING.
MOVE HP-FONT-80 TO PRINT-RECORD.
* MOVE HP-FONT-96 TO PRINT-RECORD.
* MOVE HP-FONT-132 TO PRINT-RECORD.
PERFORM 8500-WRITE-PRINT-RECORD.
MOVE SPACES TO PRINT-RECORD.
PERFORM 3000-PRINT-RECORD
UNTIL PRINTSPL-EOF.
PERFORM 8000-PAGE-EJECT.
MOVE ZERO TO LINE-SPACING.
MOVE HP-RESET TO PRINT-RECORD.
PERFORM 8500-WRITE-PRINT-RECORD.
3000-PRINT-RECORD.
MOVE PRINT-SPOOL-RECORD TO PRINT-RECORD.
PERFORM 8500-WRITE-PRINT-RECORD.
IF FIRST-TIME
MOVE LOW-VALUES TO FIRST-TIME-SW
MOVE 1 TO LINE-SPACING.
PERFORM 9000-READ-SPOOL-FILE.
8000-PAGE-EJECT.
MOVE SPACES TO PRINT-RECORD.
WRITE PRINT-RECORD BEFORE ADVANCING PAGE.
8500-WRITE-PRINT-RECORD.
WRITE PRINT-RECORD AFTER ADVANCING LINE-SPACING LINES.
9000-READ-SPOOL-FILE.
READ PRINT-SPOOL-FILE.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top