Esempio di programma Cobol che utilizza: - il file sequenziale ALUNNI1 - il file INDEXED ALUNNIX - il file di Stampa. identification division. program-id. alunnitot. environment division. configuration section. special-names. decimal-point is comma. input-output section. file-control. select alunni1 assign to disk. select stampa assign to disk. select alunnix assign to disk organization is indexed access mode is sequential record key is matx alternate record key is nomex with duplicates alternate record key is classex with duplicates. data division. file section. fd alunni1. 01 rec-alunni1. 02 nome pic x(30). 02 numtel pic x(15). 02 email pic x(20). 02 datanas pic x(10). 02 classe pic x(3). fd alunnix. 01 rec-alunnix. 02 matx pic 9(10). 02 nomex pic x(30). 02 numtelx pic x(15). 02 emailx pic x(20). 02 datanasx pic x(10). 02 classex pic x(3). fd stampa. 01 rec-stampa pic x(80). working-storage section. 77 c pic 9(10) value 0. 77 s pic 9(10) value 0. 77 fine pic 9 value 0. 01 t1 . 02 filler pic x(50) value 'numero record letti '. 02 filler pic x(2) value space. 02 cx pic 9(10). 01 t2. 02 filler pic x(50) value 'numero di record trasferiti '. 02 filler pic x(2) value space. 02 sx pic 9(10). procedure division. open input alunni1. open output stampa. open output alunnix. display '---<<>>---'. perform with test after until fine=1 read alunni1 at end move 1 to fine not at end add 1 to c move c to matx move nome to nomex move numtel to numtelx move email to emailx move classe to classex move datanas to datanasx write rec-alunnix invalid key display 'matricola errata' end-write add 1 to s end-read end-perform. display 'il numero di record letti e:'. display c. display 'il numero di record trasferiti e :'. display s. perform stampa1 thru ex-stampa1. close alunni1. close alunnix. close stampa. stop run. stampa1. move c to cx. move t1 to rec-stampa. write rec-stampa. move space to rec-stampa. move s to sx. move t2 to rec-stampa. write rec-stampa. ex-stampa1. exit.