Highlighted
Absent Member.
Absent Member.
479 views

[archive] Printing with -P SPOOLER

[Migrated content. Thread originally posted on 22 February 2007]

My problem relates to the first page of a spooled printout under version 5.2.1.1

The first page ONLY has a stray line-feed at the top which I've not been able to suppress. Following pages are fine - just page 1 will not co-operate.

Having looked for some time here, I found and adapted a "Hello World" demo:

PROGRAM-ID. PRNTEST.

FILE-CONTROL.
SELECT PRNFILE
ASSIGN TO "-P SPOOLER"
ORGANIZATION IS LINE SEQUENTIAL.

FILE SECTION.
FD PRNFILE.
01 PRNLINE PIC X(80).

WORKING-STORAGE SECTION.
01 WS-DATA.
03 CT-LINE PIC 9(03).
03 FILLER PIC X(11) VALUE "Hello World".

PROCEDURE DIVISION.
MAIN.
CALL "WIN$PRINTER" USING 17.
OPEN OUTPUT PRNFILE.
PERFORM
VARYING CT-LINE FROM 1 BY 1
UNTIL CT-LINE IS EQUAL TO 201
WRITE PRNLINE FROM WS-DATA
END-PERFORM.
CLOSE PRNFILE.
STOP RUN.

* This produces the first page with 66 lines and subsequent with 67 lines.
* The first printed line of the first page is positioned one line below that of the remainder
* Setting SET-TRAILING-SPACES to 0 or 1 had no effect
** Although replacing the "-P SPOOLER" with 'DISC "filename.txt" ' acted as expected - no initial linefeed character in the file.

I experimented further :

PROGRAM-ID. PRNTEST.

FILE-CONTROL.
SELECT PRNFILE
ASSIGN TO "-P SPOOLER"
ORGANIZATION IS LINE SEQUENTIAL.

FILE SECTION.
FD PRNFILE.
01 PRNLINE PIC X(80).

WORKING-STORAGE SECTION.
01 WS-DATA.
03 CT-LINE PIC 9(03).
88 PAGEBREAK-EXPECTED VALUES 66, 132, 198.
03 FILLER PIC X(11) VALUE "Hello World".

PROCEDURE DIVISION.
MAIN.
CALL "WIN$PRINTER" USING 17.
OPEN OUTPUT PRNFILE.
PERFORM
VARYING CT-LINE FROM 1 BY 1
UNTIL CT-LINE IS EQUAL TO 201
IF PAGEBREAK-EXPECTED
WRITE PRNLINE FROM WS-DATA AFTER PAGE
ELSE
WRITE PRNLINE FROM WS-DATA
END-IF
END-PERFORM.
CLOSE PRNFILE.
STOP RUN.

* Still had the starting linefeed
* First page was 65 lines, line 66 to 131 on second page - as expected (other than the initial blank line)
* Changing "AFTER PAGE" to "BEFORE PAGE" merrily SUPPRESSED line 66, 132. 198 - which I found odd.

So - I'm confused about why this is occurring - and how to cure it. Previous programmers on this system seem to have simply written around the issue (and every other issue 😞 rather than attempting to cure it. Really looking for ideas here...

Rgds...PW
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Printing with -P SPOOLER

This happens because the statement:
WRITE PRNLINE

has an implicit:

AFTER ADVANCING LINE


On the first page this shows because that is where the line is written, on subsequent pages however, the blank line appears at the end of the previous page.

To circumvent this, you can consequently program using the phrase BEFORE ADVANCING, like:
WRITE PRNLINE BEFORE ADVANCING 1 LINE


Hope this helps.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Printing with -P SPOOLER

Worked like a charm.:)
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.