I got this result from the code below using a COBOL PC Compiler on Windows.
REC 1
FFREC 2-AFTER PAGE
REC 3 AFTER 3REC 4
I can understand the FF at the beginning of the first line. However, the last output line puts REC 4 at the SAME LINE as record 3! My question is, does MICRO FOCUS COBOL or IBM ENTERPRISE COBOL or Fujitsu COBOL produce the same result? If yes, how to work around this to have a result file one can view on Windows? Thanks.
EDIT-1: I discovered that if I write:
MOVE "REC 4" TO FD-PRINT-REC
WRITE FD-PRINT-REC AFTER 1
Then the text "REC 4" appears on a separate line. I assume that this is not the ANSI Standard behavior, I hope you could verify what your compiler does.
EDIT-2:
Another option proposed at this thread, the "ASSIGN TO LINE ADVANCING" is probably not something that would work on ENTERPRISE COBOL (not sure): GNU COBOL Forum-Related Thread
The code:
IDENTIFICATION DIVISION.
PROGRAM-ID. CALLER.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PRINT-FILE ASSIGN TO "X.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
*> --------------------------------------------------------------
DATA DIVISION.
FILE SECTION.
FD PRINT-FILE.
01 FD-PRINT-REC PIC X(132).
*>---------------------------------------------------------------
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
OPEN OUTPUT PRINT-FILE
MOVE "REC 1" TO FD-PRINT-REC
WRITE FD-PRINT-REC
MOVE "REC 2-AFTER PAGE" TO FD-PRINT-REC
WRITE FD-PRINT-REC AFTER PAGE
MOVE "REC 3 AFTER 3" TO FD-PRINT-REC
WRITE FD-PRINT-REC AFTER 3
MOVE "REC 4" TO FD-PRINT-REC
WRITE FD-PRINT-REC
CLOSE PRINT-FILE.
STOP RUN
.