I am trying to output the the current console display to the TFileOut.da file. But when I try to write a record, all the data gets outputted into the same line.
PROGRAM-ID. TFile.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT myInFile ASSIGN TO "TestFile.dat".
SELECT myOutFile ASSIGN TO "TFileOut.dat".
DATA DIVISION.
FILE SECTION.
FD myInFile.
01 inRecord.
02 StudentName PIC X(15).
02 StudentWNbr PIC X(8).
02 Years PIC X(9).
02 Course PIC X(9).
02 CourseD PIC X(28).
02 Grade PIC X(1).
02 CreditHr PIC 9.
02 FILLER PIC X(1).
FD myOutFile.
01 studentOutRecord.
02 DatFile PIC X(10).
WORKING-STORAGE SECTION.
01 w PIC X(3) VALUE "YES".
01 stor PIC X(9).
PROCEDURE DIVISION.
OPEN INPUT myInFile.
OPEN OUTPUT myOutFile.
PERFORM subRead
PERFORM UNTIL w = "NO"
PERFORM subRead
END-PERFORM.
CLOSE myInFile.
CLOSE myOutFile.
STOP RUN.
subRead.
READ myInFile
AT END
MOVE "NO" TO w
NOT AT END
DISPLAY Course
MOVE Course TO
MOVE Course to DatFile
WRITE studentOutRecord
END-READ.
The is the output in the output file. CMPS 161 MATH 223 MATH 200 HIST 101 MATH 223 MATH 200 HIST 101 PHYS 101 MUSC 101 PSYC 101 SSYC 101
This is how I get into console.
CMPS 161
MATH 223
MATH 200
HIST 101
MATH 223
MATH 200
HIST 101
PHYS 101
MUSC 101
PSYC 101
SSYC 101
I want to display the output file same as the console.
In FILE-CONTROL set the organization to line sequential.
SELECT myInFile ASSIGN TO "TestFile.dat"
organization is line sequential.
SELECT myOutFile ASSIGN TO "TFileOut.dat"
organization is line sequential.
This will keep the line feeds intact.
I run GNUCobol under Linux and without using line sequential everything packs into one line.