如何在新行中写入记录。(在 output.dat 文件上)
How to write record in a new line.(on the output.dat ile)
我正在尝试将当前控制台显示输出到 TFileOut.da 文件。但是当我尝试写一条记录时,所有数据都输出到同一行。
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.
这是输出文件中的输出。
CMPS 161 数学 223 数学 200 HIST 101 数学 223 数学 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
我想像控制台一样显示输出文件。
在 FILE-CONTROL 中将组织设置为行顺序。
SELECT myInFile ASSIGN TO "TestFile.dat"
organization is line sequential.
SELECT myOutFile ASSIGN TO "TFileOut.dat"
organization is line sequential.
这将使换行保持完整。
我 运行 GNUCobol 在 Linux 下并且不使用行顺序,所有内容都打包成一行。
我正在尝试将当前控制台显示输出到 TFileOut.da 文件。但是当我尝试写一条记录时,所有数据都输出到同一行。
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.
这是输出文件中的输出。 CMPS 161 数学 223 数学 200 HIST 101 数学 223 数学 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
我想像控制台一样显示输出文件。
在 FILE-CONTROL 中将组织设置为行顺序。
SELECT myInFile ASSIGN TO "TestFile.dat"
organization is line sequential.
SELECT myOutFile ASSIGN TO "TFileOut.dat"
organization is line sequential.
这将使换行保持完整。
我 运行 GNUCobol 在 Linux 下并且不使用行顺序,所有内容都打包成一行。