Cobol:找不到导致文件匹配无限循环错误的原因

Cobol: Cannot Find What Is Causing Infinite Loop Error in File Matching

我一直在努力通过学校了解文件匹配。通过我的代码时,我得到了一个无限循环,但我不确定是什么导致了它。我只知道它在我的文件匹配部分代码中的某处。

01 Procedure Division.  
02   A-Para.
03      Perform Process-Para Until EOFa = "Y"
04        and EOFb = "Y"
05   Process-Para.  
06       Add 1 to counter
07       
08       If inFileSorted-empNum = timeFileSorted-empNum
09           Perform check-Para
10       End-If.
11   
12   check-Para. 
13       Perform ReadTimeFile
14       If changeEmployee equals "Y"
15           Perform Compute-Para
16       End-If
17       If timeFileSorted-empNum not equal to inFileSorted-empNum
18           Perform ReadinFile
19           If changeEmployee equals "Y"
20               Perform Compute-Para
21           End-If
22       End-If
23       
24       Perform 510-Calculate
25       Perform Display-Para.
26
27    ReadTimeFile. 
28       Move spaces to changeEmployee
29       
30       If not EOFb = "Y"
31           Move timeFileSorted-empNum to oldEmpNum              
32           Read timeFileSort             
33           At end
34               Move "Y" to EOFb
35               Move high-value to timeFileSorted-empNum
36           Not at end
37               Move timeFileSorted-empNum to newEmpNum  
38               If (oldEmpNum not equal newEmpNum)
39                   Move "Y" to changeEmployee
40               End-If
41           End-Read
42       End-If.  
43
44    ReadinFile.  
45       Move spaces to changeEmployee
46       
47       If not EOFa = "Y"
48           Move inFileSorted-empNum to oldEmpNum
49           Read Lab10-sort-File
50           At end
51               Move "Y" to EOFa
52               Move high-value to inFileSorted-empNum                  
53           Not at end
54               Move inFileSorted-empNum to newEmpNum  
55               If (oldEmpNum not equal newEmpNum)
56                  Move "Y" to changeEmployee
57               End-If
58           End-Read
59       End-If.

有人可以帮我找出导致此问题的原因吗?任何帮助将不胜感激。

一个可能的原因(在 Process-Para 中)是

08       If inFileSorted-empNum = timeFileSorted-empNum
09           Perform check-Para
10       End-If.

if inFileSorted-empNum not = timeFileSorted-empNum 它将跳过 over check-Para并且也不读取文件


更好的选择

这不是为了工作,而是为了向您展示如何构建代码。请注意每次循环至少读取一个文件

open infile, timefile
Perform read-inFile
Perform read-timeFile
perform until EOFa = "Y" or EOFb = "Y"
    evaluate true
    when inFileSorted-empNum < timeFileSorted-empNum
        ...
        Perform read-inFile
    when inFileSorted-empNum > timeFileSorted-empNum
        ...
        Perform read-timeFile
    when Other
       ...
        Perform read-timeFile  ???
    end-evaluate
end-perform

perform until EOFa = "Y"
    ...
end-perform

perform until EOFb not = "Y"
    ...
end-perform
.