[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.1The 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



