使用COBOL语言将输出保存在文件中

时间:2016-03-30 13:37:13

标签: cobol

我需要帮助在COBOL中编写一个小程序。 我写了这段代码:

IDENTIFICATION DIVISION.
PROGRAM-ID. CallC.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INITBUF PIC X(10).
01 SHOWBUF PIC X(10).
01 BUF USAGE IS POINTER.
01 NUM PIC 9(10). 
PROCEDURE DIVISION.
MOVE 10 to NUM.
CALL "getBuffer" USING BY VALUE NUM RETURNING BUF.
CALL "initBuffer" USING BY VALUE BUF RETURNING INITBUF.
CALL "showBuffer" USING BY VALUE BUF RETURNING SHOWBUF.
DISPLAY SHOWBUF.
STOP RUN.

如何将DISPLAY结果写入文件?

1 个答案:

答案 0 :(得分:1)

比尔。声明文件,如下例所示。将要输出的内容移动到输出变量中,然后写入output outputVar

 ENVIRONMENT DIVISION.                            
 CONFIGURATION SECTION.                           
 INPUT-OUTPUT SECTION.                            
 FILE-CONTROL.                                    
    SELECT PARM-OUT              ASSIGN TO PARMOUT.
*************************************************
 DATA DIVISION.                                   
 FILE SECTION.                                    

 FD  PARM-OUT                                      
  RECORDING MODE F.                            

 01  PARMIN-REC.                                  
     05  PSID-IN          PIC 9(09).              
     05  PCID-IN          PIC 9(08).              
     05  IN-PCIDSEQ       PIC 9(03).