COBOL中文件读取的问题

时间:2016-05-19 09:04:55

标签: cobol

我刚开始学习COBOL,我想读取文件Dane.txt。我在Win7中使用Microsoft COBOL编译器版本2.20(指令如何安装此编译器是我发现的第一个)。这是我的代码:

IDENTIFICATION DIVISION.
PROGRAM-ID. RAPORT.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO DISK
    ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.

FILE SECTION.

FD IN-FILE
    DATA RECORD is INPUT-RECORD
LABEL RECORDS ARE STANDARD
    VALUE OF FILE-ID IS "C:\MYCOBOL\COBOL\Dane.TXT".
01 INPUT-REC.
    05 ID-C PIC 9(5).
    05 Name         PIC X(15).
    05 ADDRESS      PIC X(8).
    05 NIP          PIC 9(10).

WORKING-STORAGE SECTION.
01 SWITCHES.
    05 EOF-SWITCH   PIC X VALUE "N".

01 COUNTERS.
    05 REC-COUNTER  PIC 9(3) VALUE 0.


PROCEDURE DIVISION.
000-MAIN.

    PERFORM 100-INITIALIZE.
    PERFORM 200-PROCESS-RECORDS
        UNTIL EOF-SWITCH = "Y".
    PERFORM 300-TERMINATE.
    STOP RUN.

100-INITIALIZE.


    OPEN INPUT IN-FILE.

    READ IN-FILE
        AT END
            MOVE "Y" TO EOF-SWITCH
    END-READ.

200-PROCESS-RECORDS.

    DISPLAY "ID    --> " ID-C.
    DISPLAY "NAME  --> " NAME.
    DISPLAY "ADDRESS --> " ADDRESS.
    DISPLAY "NIP   --> " NIP.

    READ IN-FILE
        AT END
            MOVE "Y" TO EOF-SWITCH
    END-READ.

300-TERMINATE.
    DISPLAY "THE END".
    CLOSE IN-FILE.

我从编译器消息中得到END-READ是无法识别的元素,它被忽略了。我不知道接下来该做什么。我做研究但我一无所获。也许是另一种阅读文件的方式?

2 个答案:

答案 0 :(得分:3)

您的编译有4个语法错误。

Compilation Errors

您有以下内容:

FD  IN-FILE
    DATA RECORD IS INPUT-RECORD
    LABEL RECORDS ARE STANDARD
    VALUE OF FILE-ID IS "C:\MYCOBOL\COBOL\Dane.TXT".
01  INPUT-REC.
    05 ID-C         PIC 9(5).
    05 NAME         PIC X(15).
    05 ADDRESS      PIC X(8).
    05 NIP          PIC 9(10).

在一个地方,你说INPUT-RECORD。定义记录时,将其称为INPUT-REC。修复一个或另一个。

我不知道SWITCHES有什么问题。它可能是COBOL保留字,因此将其更改为WS-SWITCHES。

最后,从两个READ语句中删除END-READ。我建议将READ语句放在自己的段落中,并将其作为启动读取和循环读取执行。

答案 1 :(得分:0)

 link : function(scope, element, attrs){
      scope.$watch(function(){return scope.arr;}, function(newValue, oldValue) {
            if(newValue != oldValue)
                console.log(scope.arr);
      });
 }

Cobol-74,以句号而不是canvas.toJSON()结束读取语句(cobol-85)