元SE。田舎の公務員

通勤快足な生活をしながら、開発技術とウェイトコントロールについてつらつらと。。。

とんでもなく眠い毎日です。

授業中寝たらアウトっぽい気配があるので、寝れません。

くるまが塩カルで真っ白になっちゃったんで、洗おうと思ったんですが、家に着いたのは20時過ぎ。
外は軽く粉雪が舞っているので諦めました。

COBOLのEX902(索引編成)一回作ってあるのに、またイチから作り直すの面倒臭いんですけど…
どうに作ったかなんて忘れてるし…
2005年9月2日に完成してるみたい。

EX704の内容でも載せてみる?

       IDENTIFICATION  DIVISION.
       PROGRAM-ID.     EX704.
       AUTHOR          hogehoge.
       ENVIRONMENT     DIVISION.
       CONFIGURATION   SECTION. 
       SOURCE-COMPUTER TOSHIBA.
       OBJECT-COMPUTER TOSHIBA.
       INPUT-OUTPUT    SECTION.
       FILE-CONTROL.
           SELECT IFILE ASSIGN TO "E:IFL.DAT"
               ORGANIZATION LINE SEQUENTIAL.
           SELECT OFILE ASSIGN TO "E:OFL.DAT".   
           SELECT SFILE ASSIGN TO "E:SFL.DAT".
       DATA            DIVISION.
       FILE            SECTION.
       FD IFILE.
       01 IREC.
          02 ICL PIC X(3).
          02 INO PIC 9(6).
          02 INA PIC X(10).
          02 ISK PIC X(2).
          02 IKA PIC 9.
          02 ITK PIC 9(3).
          02     PIC X(55).
       FD OFILE. 
       01 OREC   PIC X(132).
       SD SFILE.
       01 SREC.
          02 SCL PIC X(3).
          02 SNO PIC 9(6).
          02 SNA PIC X(10).
          02 SSK PIC X(2).
          02 SKA PIC 9.
          02 STK PIC 9(3).
       WORKING-STORAGE SECTION.
       01 WSK PIC X(10).
       01 WCL PIC X(3).
       01 WNA PIC X(10).
       01 WGK PIC 9(4). 
       01 TBL.
          02 TVALUE OCCURS 6.
             03  PIC X(12) VALUE "1A1学期中間".
             03  PIC X(12) VALUE "2A2学期中間".
             03  PIC X(12) VALUE "3A3学期中間".
             03  PIC X(12) VALUE "1B1学期期末".
             03  PIC X(12) VALUE "2B2学期期末".
             03  PIC X(12) VALUE "3B3学期期末".
       01 KTV REDEFINES TBL.
          02 KTB OCCURS 6 INDEXED BY I.
             03 KTK PIC X(2).
             03 KTN PIC X(10).  
       01 CGR.
          02 WCNI PIC 9(2).
          02 WCMA PIC 9(3).
          02 WCJP PIC 9(3).
          02 WCEN PIC 9(3). 
          02 WCGK PIC 9(3).
       01 KGR.
          02 WKNI PIC 9(2).
          02 WKMA PIC 9(3).
          02 WKJP PIC 9(3).
          02 WKEN PIC 9(3). 
          02 WKGK PIC 9(3).
       01 MIDASHI.      
          02      PIC X(10)  VALUE SPACE.
          02      PIC X(14) VALUE "試験区分".
          02      PIC X(12) VALUE "クラス".
          02      PIC X(12) VALUE "番号".
          02      PIC X(14) VALUE "氏名".
          02      PIC X(10) VALUE "数学".
          02      PIC X(10) VALUE "国語".
          02      PIC X(10) VALUE "英語".
          02      PIC X(10) VALUE "合計". 
       01 MEISAI.         
          02      PIC X(8) VALUE SPACE.
          02 OKU  PIC X(10).
          02      PIC X(8) VALUE SPACE.
          02 OCL  PIC X(3).     
          02      PIC X(5) VALUE SPACE.
          02 ONO  PIC 9(6).    
          02      PIC X(5) VALUE SPACE.
          02 ONA  PIC X(10). 
          02      PIC X(7) VALUE SPACE.
          02 OMA  PIC ZZ9. 
          02      PIC X(7) VALUE SPACE.
          02 OJP  PIC ZZ9. 
          02      PIC X(7) VALUE SPACE.
          02 OEN  PIC ZZ9. 
          02      PIC X(7) VALUE SPACE.
          02 OGK  PIC ZZ9.    
       01 CAVE.
          02      PIC X(45) VALUE SPACE.
          02      PIC X(17) VALUE "クラス平均".
          02 CMA  PIC ZZ9.9.  
          02      PIC X(5) VALUE SPACE.
          02 CJP  PIC ZZ9.9. 
          02      PIC X(5) VALUE SPACE.
          02 CEN  PIC ZZ9.9.  
          02      PIC X(5) VALUE SPACE.
          02 CGK  PIC ZZ9.9.
       01 KAVE.
          02      PIC X(47) VALUE SPACE.
          02      PIC X(15) VALUE "区分平均".
          02 KMA  PIC ZZ9.9.  
          02      PIC X(5) VALUE SPACE.
          02 KJP  PIC ZZ9.9. 
          02      PIC X(5) VALUE SPACE.
          02 KEN  PIC ZZ9.9.  
          02      PIC X(5) VALUE SPACE.
          02 KGK  PIC ZZ9.9.
       PROCEDURE       DIVISION.
      ****    MAIN    ***** 
       MAIN.
           OPEN OUTPUT OFILE
           INITIALIZE CGR KGR 
           MOVE SPACE TO OREC 
           WRITE OREC AFTER PAGE  
           WRITE OREC FROM MIDASHI AFTER 2
           SORT SFILE
               ASCENDING SSK SCL SNO
               USING IFILE 
               OUTPUT PROCEDURE S1
           CLOSE OFILE
           STOP RUN.
      ***    S1    ****
       S1.        
           RETURN SFILE
               AT END MOVE HIGH-VALUE TO SNA
           END-RETURN  
           MOVE SNA TO WNA
           MOVE SSK TO WSK
           MOVE SCL TO WCL 
           PERFORM UNTIL SNA = HIGH-VALUE  
               INITIALIZE KGR  
               PERFORM UNTIL WSK NOT = SSK OR SNA = HIGH-VALUE
                   INITIALIZE CGR    
                   SET I TO 1
                   SEARCH KTB
                      WHEN SSK = KTK(I)    
                          MOVE KTN(I) TO OKU
                   END-SEARCH 
                   PERFORM UNTIL WSK NOT = SSK OR WCL NOT = SCL 
                                 OR SNA = HIGH-VALUE 
                       INITiALIZE WGK 
                       INITIALIZE OMA OJP OEN 
                       MOVE SNO TO ONO    
                       MOVE SCL TO WCL
                       MOVE SNA TO WNA
                       PERFORM UNTIL WSK NOT = SSK OR SNA NOT = WNA 
                                     OR SNA = HIGH-VALUE
                           EVALUATE TRUE
                               WHEN SKA = 1 
                                   MOVE STK TO OMA
                                   ADD STK TO WCMA
                               WHEN SKA = 2
                                   MOVE STK TO OJP
                                   ADD STK TO WCJP
                               WHEN SKA = 3
                                   MOVE STK TO OEN
                                   ADD STK TO WCEN
                           END-EVALUATE
                           ADD STK TO WCGK
                           ADD STK TO WGK
                           RETURN SFILE 
                               AT END MOVE HIGH-VALUE TO SNA
                           END-RETURN
                       END-PERFORM
                       MOVE WGK TO OGK 
                       MOVE WNA TO ONA     
                       IF WCNI >= 1
                          THEN MOVE SPACE TO OCL
                          ELSE MOVE WCL TO OCL          
                       END-IF                 
                       IF WCNI >= 1
                          THEN MOVE SPACE TO OKU 
                       END-IF
                       WRITE OREC FROM MEISAI AFTER 2
                       ADD 1 TO WCNI
                   END-PERFORM
                   DIVIDE WCMA BY WCNI GIVING CMA
                   DIVIDE WCJP BY WCNI GIVING CJP
                   DIVIDE WCEN BY WCNI GIVING CEN
                   DIVIDE WCGK BY WCNI GIVING CGK
                   WRITE OREC FROM CAVE AFTER 2
                   ADD WCNI TO WKNI
                   ADD WCMA TO WKMA
                   ADD WCJP TO WKJP
                   ADD WCEN TO WKEN
                   ADD WCGK TO WKGK 
                   MOVE SSK TO WSK
                   MOVE SCL TO WCL 
               END-PERFORM  
               DIVIDE WKMA BY WKNI GIVING KMA
               DIVIDE WKJP BY WKNI GIVING KJP
               DIVIDE WKEN BY WKNI GIVING KEN
               DIVIDE WKGK BY WKNI GIVING KGK
               WRITE OREC FROM KAVE AFTER 2
               MOVE SSK TO WSK 
           END-PERFORM.