COBOL文件的写入
谁能给个简单点的例子。。。。。网上找了个教程。。。太繁杂了。。。看不懂!!就比如说我现在随便写几句话到“E:\TEST.TXT”文件里!怎么实现?能再简练点么。。。。我是...
谁能给个简单点的例子。。。。。网上找了个教程。。。太繁杂了。。。看不懂!!
就比如说我现在随便写几句话到“E:\TEST.TXT”文件里!怎么实现?
能再简练点么。。。。我是昨天才接触COBOL的。。。
然后我是想随便写几句话(把这几句话赋给几个变量)写到一个文件里。。。不是从一个文件里读了之后再写到另一个文件里!! 展开
就比如说我现在随便写几句话到“E:\TEST.TXT”文件里!怎么实现?
能再简练点么。。。。我是昨天才接触COBOL的。。。
然后我是想随便写几句话(把这几句话赋给几个变量)写到一个文件里。。。不是从一个文件里读了之后再写到另一个文件里!! 展开
展开全部
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUT-FILE ASSIGN TO EXER03O.
DATA DIVISION.
FILE SECTION.
FD OUT-FILE LABEL RECORD IS STANDARD RECORDING MODE IS F.
01 OUT-R.
02 OUT-REC PIC X(80).
PROCEDURE DIVISION.
S. OPEN OUTPUT OUT-FILE.
MOVE SPACE TO OUT-R.
M. MOVE 'HELLO WORD!' TO OUT-REC.
WRITE OUT-R.
E. CLOSE IN-FILE , OUT-FILE.
STOP RUN.
可以随便些什么到出力文件,但是如果要输出到E:\TEST.TXT文件中,需要你在编译或者执行环境中指定才行
PROGRAM-ID. TEST1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUT-FILE ASSIGN TO EXER03O.
DATA DIVISION.
FILE SECTION.
FD OUT-FILE LABEL RECORD IS STANDARD RECORDING MODE IS F.
01 OUT-R.
02 OUT-REC PIC X(80).
PROCEDURE DIVISION.
S. OPEN OUTPUT OUT-FILE.
MOVE SPACE TO OUT-R.
M. MOVE 'HELLO WORD!' TO OUT-REC.
WRITE OUT-R.
E. CLOSE IN-FILE , OUT-FILE.
STOP RUN.
可以随便些什么到出力文件,但是如果要输出到E:\TEST.TXT文件中,需要你在编译或者执行环境中指定才行
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
000010 IDENTIFICATION DIVISION.
000060 PROGRAM-ID. AKITA.
000070*
000080 ENVIRONMENT DIVISION.
000090 INPUT-OUTPUT SECTION.
000100 FILE-CONTROL.
000110 SELECT WINFILE1 ASSIGN TO FILE01-MSD
000120 ORGANIZATION IS SEQUENTIAL
000130 FILE STATUS WFSTS1.
000140 SELECT AVXFILE1 ASSIGN TO FILE02-FDU
000150 ORGANIZATION IS SEQUENTIAL
000160 FILE STATUS AFSTS1.
000170 I-O-CONTROL.
000180 APPLY EXCLUSIVE-MODE ON WINFILE1.
000190*
000200 DATA DIVISION.
000210 FILE SECTION.
000220 FD WINFILE1
000230 BLOCK CONTAINS 256 CHARACTERS
000240 LABEL RECORD IS STANDARD
000250 VALUE OF IDENTIFICATION IS "WINFILE01".
000260 01 WINREC.
000270 02 A1 PIC X(80).
000280 02 A2 PIC X(176).
000290 FD AVXFILE1
000300 BLOCK CONTAINS 240 CHARACTERS
000310 RECORD CONTAINS 80 CHARACTERS
000320 LABEL RECORD IS STANDARD
000330 VALUE OF IDENTIFICATION IS "SWPATCH".
000340 01 AVXREC PIC X(80).
000350*
000360 WORKING-STORAGE SECTION.
000370 01 WFSTS1 PIC X(02).
000380 01 AFSTS1 PIC X(02).
000390*
000400 01 EFLAG PIC X(03).
000410*
000420 PROCEDURE DIVISION.
000470 MPROG.
000480 OPEN OUTPUT WINFILE1
000490 INPUT AVXFILE1.
000500 MOVE "LOP" TO EFLAG.
000510 PERFORM UNTIL EFLAG = "END"
000520 READ AVXFILE1
000530 AT END
000540 MOVE "END" TO EFLAG
000550 NOT AT END
000560 MOVE AVXREC TO A1
000570 WRITE WINREC
000580 END-READ
000590 END-PERFORM.
000600 CLOSE WINFILE1
000610 AVXFILE1.
000620 STOP RUN.
000060 PROGRAM-ID. AKITA.
000070*
000080 ENVIRONMENT DIVISION.
000090 INPUT-OUTPUT SECTION.
000100 FILE-CONTROL.
000110 SELECT WINFILE1 ASSIGN TO FILE01-MSD
000120 ORGANIZATION IS SEQUENTIAL
000130 FILE STATUS WFSTS1.
000140 SELECT AVXFILE1 ASSIGN TO FILE02-FDU
000150 ORGANIZATION IS SEQUENTIAL
000160 FILE STATUS AFSTS1.
000170 I-O-CONTROL.
000180 APPLY EXCLUSIVE-MODE ON WINFILE1.
000190*
000200 DATA DIVISION.
000210 FILE SECTION.
000220 FD WINFILE1
000230 BLOCK CONTAINS 256 CHARACTERS
000240 LABEL RECORD IS STANDARD
000250 VALUE OF IDENTIFICATION IS "WINFILE01".
000260 01 WINREC.
000270 02 A1 PIC X(80).
000280 02 A2 PIC X(176).
000290 FD AVXFILE1
000300 BLOCK CONTAINS 240 CHARACTERS
000310 RECORD CONTAINS 80 CHARACTERS
000320 LABEL RECORD IS STANDARD
000330 VALUE OF IDENTIFICATION IS "SWPATCH".
000340 01 AVXREC PIC X(80).
000350*
000360 WORKING-STORAGE SECTION.
000370 01 WFSTS1 PIC X(02).
000380 01 AFSTS1 PIC X(02).
000390*
000400 01 EFLAG PIC X(03).
000410*
000420 PROCEDURE DIVISION.
000470 MPROG.
000480 OPEN OUTPUT WINFILE1
000490 INPUT AVXFILE1.
000500 MOVE "LOP" TO EFLAG.
000510 PERFORM UNTIL EFLAG = "END"
000520 READ AVXFILE1
000530 AT END
000540 MOVE "END" TO EFLAG
000550 NOT AT END
000560 MOVE AVXREC TO A1
000570 WRITE WINREC
000580 END-READ
000590 END-PERFORM.
000600 CLOSE WINFILE1
000610 AVXFILE1.
000620 STOP RUN.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询