我的 COBOL 行出现问题
我有一个小问题无法解决。我的输出行显示错误。例如,我有一行应该显示如下:
123-45-6789 JS Doe Second Yr Planning 88 266 3.02
但显示如下:
123-45-6789 JS Doe Second Yr Planning 88 266
3.02
任何人都知道如何解决这个问题。我以前从未遇到过这个问题。
这是行的存储区域
01 DETAIL-LINE.
05 DL-FIRST-NUM PIC X(3).
05 DL-DASH-1 PIC X VALUE '-'.
05 DL-SECOND-NUM PIC XX.
05 DL-DASH-2 PIC X VALUE '-'.
05 DL-THIRD-NUM PIC X(4).
05 BLANK-A-OUT PIC X(3) VALUE SPACES.
05 DL-FIRST-LETTER PIC X.
05 BLANK-B-OUT PIC X VALUE SPACES.
05 DL-SECOND-LETTER PIC X.
05 BLANK-C-OUT PIC X VALUE SPACES.
05 DL-LAST-NAME PIC X(9).
05 BLANK-D-OUT PIC X(2) VALUE SPACES.
05 DL-CLASS-STANDING PIC X(9).
05 BLANK-E-OUT PIC X(3) VALUE SPACES.
05 DL-MAJOR PIC X(13).
05 BLANK-F-OUT PIC X(3) VALUE SPACES.
05 DL-HOURS PIC ZZ9.
05 BLANK-G-OUT PIC X(5) VALUE SPACES.
05 DL-POINTS PIC ZZ9.
05 BLANK-H-OUT PIC X(4) VALUE SPACES.
05 DL-GPA PIC 9.99.
,这是将其写出的代码
400-PROCESS-ONE-RECORD.
IF LINE-COUNT >= 52
PERFORM 600-NEXT-PAGE
END-IF
ADD 2 TO LINE-COUNT
MOVE SSN-IN TO SSN-BREAK
MOVE FIRST-NUM TO DL-FIRST-NUM
MOVE SECOND-NUM TO DL-SECOND-NUM
MOVE THIRD-NUM TO DL-THIRD-NUM
MOVE STUDENT-NAME-IN TO NAME-BREAK
MOVE FIRST-LETTER TO DL-FIRST-LETTER
MOVE SECOND-LETTER TO DL-SECOND-LETTER
MOVE LAST-NAME TO DL-LAST-NAME
IF CLASS-STANDING-IN = 0
MOVE 'HIGH SCHOOL' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 1
MOVE 'First Yr' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 2
MOVE 'Second Yr' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 3
MOVE 'PROGRAM 60' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = ' ' OR 4
MOVE ' ' TO DL-CLASS-STANDING
END-IF
IF MAJOR-IN = 'NES'
MOVE 'Net Security' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'NET'
MOVE 'Networking' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'PGM'
MOVE 'Programming' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'DIG'
MOVE 'Digital Media' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'COR'
MOVE ' ' TO DL-MAJOR
END-IF
MOVE CREDIT-HOURS-IN TO DL-HOURS
IF MAJOR-IN = 'NES'
ADD 1 TO NES-TOTAL
END-IF
IF MAJOR-IN = 'NET'
ADD 1 TO NET-TOTAL
END-IF
IF MAJOR-IN = 'PGM'
ADD 1 TO PGM-TOTAL
END-IF
IF MAJOR-IN = 'DIG'
ADD 1 TO DIG-TOTAL
END-IF
MOVE CREDIT-POINTS-IN TO DL-POINTS
COMPUTE TOTAL-GPA ROUNDED
= CREDIT-POINTS-IN / CREDIT-HOURS-IN
IF MAJOR-IN = 'NES' AND TOTAL-GPA > '3.O'
ADD 1 TO NES-GPA
END-IF
IF MAJOR-IN = 'NET' AND TOTAL-GPA > '3.O'
ADD 1 TO NET-GPA
END-IF
IF MAJOR-IN = 'PGM' AND TOTAL-GPA > '3.O'
ADD 1 TO PGM-GPA
END-IF
IF MAJOR-IN = 'DIG' AND TOTAL-GPA > '3.O'
ADD 1 TO DIG-GPA
END-IF
MOVE TOTAL-GPA TO DL-GPA
MOVE DETAIL-LINE TO STUDENTS-RECORD-OUT
IF DL-CLASS-STANDING = 'First Yr' OR 'Second Yr' AND
GRAD-STAT-IN = ' ' OR 'X'
ADD CREDIT-POINTS-IN TO TOTAL-POINTS
ADD CREDIT-HOURS-IN TO TOTAL-HOURS
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINES
END-IF.
I am having a little issue I cannot solve. My lines are showing up wrong on my output. For example I have a line that is suppose to show up like this:
123-45-6789 J S Doe Second Yr Programming 88 266 3.02
but instead is showing up like this:
123-45-6789 J S Doe Second Yr Programming 88 266
3.02
Anyone know how to fix this. I have never encountered this problem before.
Here are is the storage area for the lines
01 DETAIL-LINE.
05 DL-FIRST-NUM PIC X(3).
05 DL-DASH-1 PIC X VALUE '-'.
05 DL-SECOND-NUM PIC XX.
05 DL-DASH-2 PIC X VALUE '-'.
05 DL-THIRD-NUM PIC X(4).
05 BLANK-A-OUT PIC X(3) VALUE SPACES.
05 DL-FIRST-LETTER PIC X.
05 BLANK-B-OUT PIC X VALUE SPACES.
05 DL-SECOND-LETTER PIC X.
05 BLANK-C-OUT PIC X VALUE SPACES.
05 DL-LAST-NAME PIC X(9).
05 BLANK-D-OUT PIC X(2) VALUE SPACES.
05 DL-CLASS-STANDING PIC X(9).
05 BLANK-E-OUT PIC X(3) VALUE SPACES.
05 DL-MAJOR PIC X(13).
05 BLANK-F-OUT PIC X(3) VALUE SPACES.
05 DL-HOURS PIC ZZ9.
05 BLANK-G-OUT PIC X(5) VALUE SPACES.
05 DL-POINTS PIC ZZ9.
05 BLANK-H-OUT PIC X(4) VALUE SPACES.
05 DL-GPA PIC 9.99.
and here is the code to write it out
400-PROCESS-ONE-RECORD.
IF LINE-COUNT >= 52
PERFORM 600-NEXT-PAGE
END-IF
ADD 2 TO LINE-COUNT
MOVE SSN-IN TO SSN-BREAK
MOVE FIRST-NUM TO DL-FIRST-NUM
MOVE SECOND-NUM TO DL-SECOND-NUM
MOVE THIRD-NUM TO DL-THIRD-NUM
MOVE STUDENT-NAME-IN TO NAME-BREAK
MOVE FIRST-LETTER TO DL-FIRST-LETTER
MOVE SECOND-LETTER TO DL-SECOND-LETTER
MOVE LAST-NAME TO DL-LAST-NAME
IF CLASS-STANDING-IN = 0
MOVE 'HIGH SCHOOL' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 1
MOVE 'First Yr' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 2
MOVE 'Second Yr' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = 3
MOVE 'PROGRAM 60' TO DL-CLASS-STANDING
END-IF
IF CLASS-STANDING-IN = ' ' OR 4
MOVE ' ' TO DL-CLASS-STANDING
END-IF
IF MAJOR-IN = 'NES'
MOVE 'Net Security' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'NET'
MOVE 'Networking' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'PGM'
MOVE 'Programming' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'DIG'
MOVE 'Digital Media' TO DL-MAJOR
END-IF
IF MAJOR-IN = 'COR'
MOVE ' ' TO DL-MAJOR
END-IF
MOVE CREDIT-HOURS-IN TO DL-HOURS
IF MAJOR-IN = 'NES'
ADD 1 TO NES-TOTAL
END-IF
IF MAJOR-IN = 'NET'
ADD 1 TO NET-TOTAL
END-IF
IF MAJOR-IN = 'PGM'
ADD 1 TO PGM-TOTAL
END-IF
IF MAJOR-IN = 'DIG'
ADD 1 TO DIG-TOTAL
END-IF
MOVE CREDIT-POINTS-IN TO DL-POINTS
COMPUTE TOTAL-GPA ROUNDED
= CREDIT-POINTS-IN / CREDIT-HOURS-IN
IF MAJOR-IN = 'NES' AND TOTAL-GPA > '3.O'
ADD 1 TO NES-GPA
END-IF
IF MAJOR-IN = 'NET' AND TOTAL-GPA > '3.O'
ADD 1 TO NET-GPA
END-IF
IF MAJOR-IN = 'PGM' AND TOTAL-GPA > '3.O'
ADD 1 TO PGM-GPA
END-IF
IF MAJOR-IN = 'DIG' AND TOTAL-GPA > '3.O'
ADD 1 TO DIG-GPA
END-IF
MOVE TOTAL-GPA TO DL-GPA
MOVE DETAIL-LINE TO STUDENTS-RECORD-OUT
IF DL-CLASS-STANDING = 'First Yr' OR 'Second Yr' AND
GRAD-STAT-IN = ' ' OR 'X'
ADD CREDIT-POINTS-IN TO TOTAL-POINTS
ADD CREDIT-HOURS-IN TO TOTAL-HOURS
WRITE STUDENTS-RECORD-OUT
AFTER ADVANCING 1 LINES
END-IF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于换行符有几种可能的解释。
第一个要消除的解释是由以下原因引起的换行
无论您在什么设备上显示输出。基于
DETAIL-LINE
记录您提供的布局中,换行发生在第 72 列。可疑。您的输出设备(例如屏幕或文件)是否在第 72 列换行下
一个可能的解释涉及一些非空格字符,例如换行符,
存储在
BLANK-H-OUT
中。这可能是由于任意数量的编程错误而发生的程序中的其他地方。未检查的越界数组/表引用通常是
这种事情的来源。解决这个问题需要一些真正的调试。
There are a couple of possible explanations for the line break.
The first explanation to eliminate is line wrapping caused by
whatever device you are displaying output on. Based on the
DETAIL-LINE
recordlayout you have provided, the wrap occurs at column 72. Suspicious. Does your output device (eg. screen, or file) wrap lines at column 72
The next possible explanation involves some non-SPACE character, such as a line feed,
stored in
BLANK-H-OUT
. This may have happened through any number of programming goofselsewhere in the program. Unchecked out of bounds array/table references are often the
source of this sort of thing. Working this out will take some real debugging.
您正在写入 72 个字符宽的文件吗?我的预感是你的记录太短了 3 个字符。
您可以发布您的文件部分吗?
Are you writing to a 72 character wide file? My hunch is that your record is 3 characters too short.
Can you post your File Section?