我的 COBOL 行出现问题

发布于 2024-10-05 18:16:29 字数 3916 浏览 8 评论 0原文

我有一个小问题无法解决。我的输出行显示错误。例如,我有一行应该显示如下:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终陌 2024-10-12 18:16:29

对于换行符有几种可能的解释。

第一个要消除的解释是由以下原因引起的换行
无论您在什么设备上显示输出。基于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 record
layout 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 goofs
elsewhere 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.

野鹿林 2024-10-12 18:16:29

您正在写入 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文