       IDENTIFICATION DIVISION.
       program-id. oefening-16-d.
       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 9(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 "Wil je nog een record (CD) t
      -        "oevoegen?".
               03 keuze pic 9.
               03 zoeknr pic x(4).
               03 zoeknaam pic x(20).

       01 cd-info.
           03 i-C-nummer pic x(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 "hoe wilt u zoeken?" at 0825
                   display "1) op nummer" at 0925
                   display "2) op titel" at 1025
                   display "3) op uitvoerder" at 1125
                   display "4) op genre-nr" at 1225
                   accept keuze at 1325
                   if keuze=1
                   perform zoek-op-nr
                   end-if
                   if keuze=2
                   perform zoek-op-titel
                   end-if
                   if keuze=3
                   perform zoek-op-uitv
                   end-if
                   if keuze=4
                   perform zoek-op-genre
                   end-if
                   .
       zoek-op-nr.
           display spaces upon crt
           display "geef een nr in" at 0625
           accept zoeknr at 0640
           move zoeknr to C-nummer
           read cdbestand key is C-nummer
           invalid key exit program
           not invalid key display C-nummer at 0640
           display C-titel at 0740
           display C-uitvoerder at 0840
           display C-aantal at 0940
           display C-genre-nr at 1040
           display C-prijs at 1140
           display C-releasedatum at 1240
                   accept verder at 1962
                   perform with test before until verdergoed
                   display "Foutieve keuze" at 2135
                       accept verder at 1962
               end-perform
           end-read

       .
       zoek-op-titel.
           display spaces upon crt
           display "geef een naam in" at 0625
           accept zoeknaam at 0650
           move zoeknaam to C-titel
           start cdbestand key >=C-titel
           invalid key exit program
           not invalid key read cdbestand next
           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
           display C-nummer at 0940
           display C-titel at 1040
           display C-aantal at 1240
           display C-genre-nr at 1340
           display C-prijs at 1440
           display C-releasedatum at 1540
                   accept verder at 1962
                   perform with test before until verdergoed
                   display "Foutieve keuze" at 2135
                       accept verder at 1962
               end-perform


       .
       zoek-op-uitv.
           display spaces upon crt
           display "geef een naam in" at 0625
           accept zoeknaam at 0650
           move zoeknaam to C-uitvoerder
           start cdbestand key >= C-uitvoerder
           invalid key exit program
           not invalid key read cdbestand next
           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
           display C-nummer at 0940
           display C-titel at 1040
           display C-aantal at 1240
           display C-genre-nr at 1340
           display C-prijs at 1440
           display C-releasedatum at 1540
                   accept verder at 1962
                   perform with test before until verdergoed
                   display "Foutieve keuze" at 2135
                       accept verder at 1962
               end-perform

       .
       zoek-op-genre.


           display spaces upon crt
           display "geef een genre in" at 0625
           accept zoeknaam at 0640
           move zoeknr to C-nummer
           read cdbestand key is C-nummer
           invalid key exit program
           not invalid key display C-nummer at 0640
           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
           display C-nummer at 0940
           display C-titel at 1040
           display C-aantal at 1240
           display C-genre-nr at 1340
           display C-prijs at 1440
           display C-releasedatum at 1540
                   accept verder at 1962
                   perform with test before until verdergoed
                   display "Foutieve keuze" at 2135
                       accept verder at 1962
               end-perform
           end-read

       .


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

               exit program.


