-- RT_C132A2A1 : Lecture du fichier digits.txt de 1 000 000 de chiffres au hasard -- et création d'un fichier de caractères -- Coyright Jacques-deric Rouault -- Version 1.3 du 20120227 WITH Text_io, sequential_io; USE Text_io; PROCEDURE RT_C132A2A1 IS ftxt : File_type; Subtype s71 IS String (1..71); str : s71; PACKAGE sioc IS NEW sequential_io (Character); fc : sioc.File_type; ------------------------------------------------------------------------------------------------------- PROCEDURE traite1 IS rangdeb : INTEGER; BEGIN rangdeb:=9; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=15; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=22; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=28; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=35; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=41; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=48; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=54; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=61; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=67; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; New_line; END traite1; ------------------------------------------------------------------------------------------------------- PROCEDURE traite2 IS rangdeb : INTEGER; BEGIN rangdeb:=9; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=15; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=22; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=28; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=35; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=41; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=48; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=54; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=61; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; rangdeb:=67; put (str(rangdeb..rangdeb+4)); put (" "); FOR r IN REVERSE rangdeb..rangdeb+4 LOOP sioc.write (fc,str(r)); END LOOP; New_line; END traite2; ------------------------------------------------------------------------------------------------------- BEGIN Put_line ("Debut d'execution du programme Ada RT_C132A2A1"); sioc.Create (fc,sioc.out_file,"RT_C132A2A3.dat"); Open (ftxt,in_file,"digits.txt"); FOR i IN 1..19999 LOOP get (ftxt,str); traite1; END LOOP; Close (ftxt); Open (ftxt,in_file,"digits.txt"); FOR i IN 1..2 LOOP get (ftxt,str); traite2; END LOOP; Close (ftxt); sioc.Close (fc); Put_line ("Fin d'execution du programme Ada RT_C132A2A1"); END RT_C132A2A1;