identification division.
program-id. Ricerca-Parametrica.
author. Matteo.
environment division.
input-output section.
file-control.
select seq assign to disk.
data division.
file section.
fd seq
label record is standard
value of file-id is "File.dat".
01 rec-s.
02 campo-1 pic x(30).
02 campo-2 pic x(30).
02 campo-3 pic x(30).
working-storage section.
77 fine-file pic xx.
77 campo-a pic x(30).
77 conta pic 99.
77 num-rec pic 99.
77 i pic 99.
procedure division.
inizio.
perform crea-file.
perform cerca-record.
stop run.
cerca-record.
display " "
display "Inserire record da cercare: " with no advancing.
accept campo-a.
open input seq.
read seq
at end
move "si" to fine-file
not at end
move "no" to fine-file
end-read.
set conta to 0.
perform confronta until fine-file = "si".
close seq.
display "Trovati " conta " record".
confronta.
if campo-1 = campo-a then
display rec-s
add 1 to conta
end-if.
read seq at end move "si" to fine-file.
crea-file.
open output seq.
display "Dimmi quanti record creare: " with no advancing.
accept num-rec.
set i to 1.
perform until i > num-rec
display " "
display "Inserire record numero " i
display " Inserire campo 1: " with no advancing
accept campo-1
display " Inserire campo 2: " with no advancing
accept campo-2
display " Inserire campo 3: " with no advancing
accept campo-3
write rec-s
add 1 to i.
close seq.