       IDENTIFICATION DIVISION.
       program-id. oefening-16-b.
       author. Levy De Vos.
       date-written. 03-november-04.

       environment division.
        configuration section.
         source-computer. pc.
         object-computer. pc.
       input-output section.
       file-control.
           select CDbestand
               assign to random "CD-ISAM.dat"
               organization is indexed
               access mode is dynamic
               record key is C-nummer
               alternate record key C-titel
               alternate record key C-uitvoerder with duplicates
               alternate record key C-genre-nr with duplicates
               file status is CD-status.

           select genrebestand
               assign to random "GENRE.dat"
               organization is indexed
               access mode is dynamic
               record key is G-code
               file status is genre-status.

       DATA DIVISION.
        file section.
           fd CDbestand
           data record is CD-ISAMrecord.
             01 CD-ISAMrecord.
               03 C-nummer pic x(4).
               03 C-titel pic X(20).
               03 C-uitvoerder pic X(20).
               03 C-aantal pic 99.
               03 C-genre-nr pic x(2).
               03 C-prijs pic 9(4).
               03 C-releasedatum pic 99/99/99.
           fd genrebestand
           data record is GENRErecord.
             01 GENRErecord.
               03 G-code pic 9(2).
               03 G-omschrijving pic X(20).



       WORKING-STORAGE SECTION.
           01 scherm-1.
               03 lijn-11 pic x(15) value "HOGESCHOOL Gent".
               03 lijn-12 pic x(12) value "Levy De Vos".
               03 lijn-13 pic x(11) value "Opgave 16".
               03 lijn-14 pic x(20) value "TOEVOEGEN CD-RECORDS".
               03 lijn-112 pic x(40) value "Nog een wijziging?".
               03 nummer pic 9(4).

       01 cd-info.
           03 i-C-nummer pic 9(4).
           03 i-C-titel pic X(20).
           03 i-C-uitvoerder pic X(20).
           03 i-C-aantal pic 99.
           03 i-C-genre-nr pic 9(2).
           03 i-C-prijs pic 9(4).
           03 i-C-releasedatum pic 99/99/99.
       01 CD-status PIC XX.
           88 eof-cdstatus value "10".

       01 genre-info.
           03 i-G-code pic 9(2).
           03 i-G-omschrijving pic X(20).
       01 genre-status PIC XX.
           88 eof-genre-status value "10".
       01 verder pic x.
           88 verdergoed values "J", "j", "N", "n".
           88 verderstop values "n", "N".

       PROCEDURE DIVISION.
       perform bprog
       perform body with test before until verderstop
       perform eprog
       stop run
           .

       bprog.
               open I-O CDbestand.
               open I-O GENREbestand.

       body.
               perform vrecord.
       eprog.
               close CDbestand.
               close GENREbestand.

       vrecord.
                   initialize i-C-nummer
                   initialize i-C-titel
                   initialize i-C-uitvoerder
                   initialize i-C-aantal
                   initialize i-C-genre-nr
                   initialize i-C-prijs
                   initialize i-C-releasedatum
                   initialize verder
                   display spaces upon crt
                   display lijn-11 at 0202
                   display lijn-12 at 2402
                   display lijn-13 at 2470
                   display lijn-14 at 0525
                   display lijn-112 at 1924
                   display "te wijzigen cd" at 0825
                   accept nummer at 0850
                   move nummer to C-nummer
                   start cdbestand
                       invalid key display "fout"
                       not invalid key read CDbestand next
                   display C-nummer at 1040
                   display C-uitvoerder at 1140
                   display C-aantal at 1240
                   display C-genre-nr at 1340
                   display C-prijs at 1440
                   display C-releasedatum at 1540
                   display "nummer" at 0925
                   display "titel" at 1025
                   display "uitvoerder" at 1125
                   display "aantal" at 1225
                   display "genre-nr" at 1325
                   display "prijs" at 1425
                   display "releasedatum" at 1525
                   accept i-C-titel at 1040
                   accept i-C-uitvoerder at 1140
                   accept i-C-aantal at 1240
                   accept i-C-genre-nr at 1340
                   accept i-C-prijs at 1440
                   accept i-C-releasedatum at 1540
                   rewrite CD-ISAMrecord from cd-info
                   move i-C-genre-nr to i-G-code
                   rewrite GENRErecord from genre-info

                   accept verder at 1942
                   perform with test before until verdergoed
                   display "Foutieve keuze" at 2135
                       accept verder at 1962
               end-perform
                   display "              " at 2135.

               exit program.


