Cobol Help

Discussion in 'OT Technology' started by El Rudo, May 5, 2007.

  1. El Rudo

    El Rudo The Borinqueneers

    Joined:
    Jun 27, 2003
    Messages:
    9,295
    Likes Received:
    0
    I'm working on my final exam and the teacher was suppose to email me back on why my code was making the complier shut down. Since he hasn't gotten back to me I came to ask if anyone could help me out. It complies but when I run it, the complier shuts down.

    Thanx in advance.

    Code:
                IDENTIFICATION DIVISION.
           PROGRAM-ID.     FINALEXAXREVIEW.
           AUTHOR.         LEO.
           DATE-WRITTEN. MAY 3, 2007.
          ******************************************************************
          * DOCUMENTATION GOES HERE
          *
          ******************************************************************
    
           ENVIRONMENT DIVISION.
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
    
               SELECT STUDENT-FILE ASSIGN TO "G:\PFEXAM\INPUT.TXT"
                   ORGANIZATION IS LINE SEQUENTIAL.
    
               SELECT STUDENT-OUTPUT ASSIGN TO "G:\PFEXAM\OUTPUT.TXT"
                   ORGANIZATION IS LINE SEQUENTIAL.
    
          ****************************************************************
           DATA DIVISION.
           FILE SECTION.
    
           FD STUDENT-FILE.
           01  STUDENT-RECORD.
               05  F-NAME-IN        PIC X(10).
               05  L-NAME-IN        PIC X(10).
               05  CODE-IN          PIC 9.
    
    
    
           FD STUDENT-OUTPUT.
           01  STUDENT-REPORT     PIC X(133).
    
           WORKING-STORAGE SECTION.
    
           01  ARE-THERE-MORE-RECORDS      PIC X VALUE "Y".
    
    
    
           01 COUNT-HISTORY                 PIC 999 VALUE ZEROS.
           01 COUNT-ENGLISH                 PIC 999 VALUE ZEROS.
           01 COUNT-MATH                    PIC 999 VALUE ZEROS.
           01 COUNT-SCI                     PIC 999 VALUE ZEROS.
           01 STUDENT-TOTAL                 PIC 999 VALUE ZEROS.
           01 DEGREE-NAME                   PIC X(11).
    
    
    
           01  HEADING-LINES.
               05          PIC X(5).
               05          PIC X(10)    VALUE "FIRST NAME".
               05          PIC X(5).
               05          PIC X(9)     VALUE "LAST NAME".
               05          PIC X(5).
               05          PIC X(15)     VALUE "COURSE OF STUDY".
    
    
    
    
    
           01  DETAIL-LINES.
               05                    PIC X(5).
               05 F-NAME-OUT         PIC X(10).
               05                    PIC X(5).
               05 L-NAME-OUT         PIC X(9).
               05                    PIC X(5).
               05 DEGREE-OUT         PIC X(11).
    
    
    
    
    
    
    
           01  HISTORY-COUNTER.
               05          PIC X(9) VALUE "HISTORY: ".
               05          PIC X(3)  VALUE SPACES.
               05  COUNT-HISTORY-OUT PIC 999 VALUE ZEROS.
    
           01  ENGLISH-COUNTER.
               05          PIC X(9) VALUE "ENGLISH ".
               05          PIC X(3)  VALUE SPACES.
               05  COUNT-ENGLISH-OUT PIC 999 VALUE ZEROS.
    
           01  MATH-COUNTER.
               05          PIC X(12) VALUE "MATHEMATICS ".
               05          PIC X(6)  VALUE SPACES.
               05  COUNT-MATH-OUT PIC 999 VALUE ZEROS.
    
           01  SCI-COUNTER.
               05          PIC X(8) VALUE "SCIENCE ".
               05          PIC X(3)  VALUE SPACES.
               05  COUNT-SCI-OUT PIC 999 VALUE ZEROS.
    
    
    
    
    
           01  TOTAL-STUDENTS.
               05           PIC X(23) VALUE " TOTAL # OF STUDENTS: ".
               05           PIC X(3).
               05  TOTAL-STUDENTS-OUT PIC 999 VALUE ZEROS.
          ******************************************************************
           PROCEDURE DIVISION.
           100-MAIN-MODULE.
               PERFORM 100-MAIN-MODULE.
               PERFORM 110-OPEN-MODULE.
               PERFORM 120-READ-MODULE.
               PERFORM 130-HEADING-MODULE.
               PERFORM 200-PROCESS-MODULE
                   UNTIL ARE-THERE-MORE-RECORDS ="N"
              PERFORM 300-TOTAL-MODULE.
              PERFORM 400-CLOSE-MODULE.
    
              STOP RUN.
    
           110-OPEN-MODULE.
               OPEN INPUT STUDENT-FILE
                   OUTPUT STUDENT-OUTPUT.
    
           120-READ-MODULE.
               READ STUDENT-FILE
                   AT END MOVE "N" TO ARE-THERE-MORE-RECORDS.
    
           130-HEADING-MODULE.
               MOVE HEADING-LINES TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
           200-PROCESS-MODULE.
               ADD 1 TO STUDENT-TOTAL.
    
    
    
    
               PERFORM 240-MAJOR-CODE-MODULE
    
    
               MOVE F-NAME-IN TO F-NAME-OUT.
               MOVE L-NAME-IN TO L-NAME-OUT.
               MOVE DEGREE-NAME TO DEGREE-OUT.
    
    
               MOVE DETAIL-LINES TO STUDENT-REPORT
                   WRITE STUDENT-REPORT.
    
    
    
    
    
    
    
    
    
    
    
    
           240-MAJOR-CODE-MODULE.
               EVALUATE CODE-IN
    
                   WHEN 1
                       MOVE "HISTORY" TO DEGREE-NAME
                       ADD 1 TO COUNT-HISTORY
                   WHEN 2
                       MOVE "ENGLISH" TO DEGREE-NAME
                       ADD 1 TO COUNT-ENGLISH
                   WHEN 3
                       MOVE "MATHEMATICS" TO DEGREE-NAME
                       ADD 1 TO COUNT-MATH
                   WHEN 4
                       MOVE "SCIENCE" TO DEGREE-NAME
                       ADD 1 TO COUNT-SCI
    
               END-EVALUATE.
    
    
    
           300-TOTAL-MODULE.
    
               MOVE COUNT-HISTORY TO COUNT-HISTORY-OUT
               MOVE COUNT-ENGLISH TO COUNT-ENGLISH-OUT
               MOVE COUNT-MATH TO COUNT-MATH-OUT
               MOVE COUNT-SCI TO COUNT-SCI-OUT
               MOVE STUDENT-TOTAL TO TOTAL-STUDENTS-OUT
    
               MOVE HISTORY-COUNTER TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
               MOVE ENGLISH-COUNTER TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
               MOVE MATH-COUNTER TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
               MOVE SCI-COUNTER TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
    
               MOVE TOTAL-STUDENTS TO STUDENT-REPORT
                   WRITE STUDENT-REPORT
                       AFTER ADVANCING 2 LINES.
    
    
           400-CLOSE-MODULE.
               CLOSE STUDENT-FILE
                   STUDENT-OUTPUT.
    
    
     
  2. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    If you're crashing the development environment, it's most likely either an array overflow or a segmentation fault, but if you're messing around with capturing OS API handles, you could be using an API call that's causing the OS to shut the development environment down as a side effect. I have that happen with one project I work on in VB6 that uses a lot of Windows APIs -- every single time I end the program while test-running it, VB6 kills itself, so I have to write separate test projects for all the new code I add to the main project.
     

Share This Page