From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.233.137 with SMTP id tw9mr7224885pac.47.1452477548034; Sun, 10 Jan 2016 17:59:08 -0800 (PST) X-Received: by 10.182.241.195 with SMTP id wk3mr1169872obc.8.1452477547978; Sun, 10 Jan 2016 17:59:07 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h5no2806612igh.0!news-out.google.com!kr2ni1472igb.0!nntp.google.com!h5no2806603igh.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 10 Jan 2016 17:59:07 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.6.21.101; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 24.6.21.101 References: <77e47c8b-7dcc-4e86-8f89-1f348cdf08dd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Re-write a file in Ada From: Anh Vo Injection-Date: Mon, 11 Jan 2016 01:59:08 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:29083 Date: 2016-01-10T17:59:07-08:00 List-Id: On Sunday, January 10, 2016 at 2:57:42 PM UTC-8, comicf...@gmail.com wrote: > Thanks bj=F6rn lundin and the others ! >=20 > I finally suceed : >=20 > WITH Ada.Text_IO ; USE Ada.Text_IO ; > WITH Ada.Text_IO.Unbounded_IO ; USE Ada.Text_IO.Unbounded_IO ; > WITH Ada.Strings.Unbounded ; USE Ada.Strings.Unbounded ; >=20 > Procedure main is >=20 > next_l : Positive_Count :=3D 1 ; >=20 > this_file : File_type ; >=20 > f_deux : File_type ; >=20 > Type T_Tableau is array( 1 .. 1_000 ) of unbounded_string ; >=20 > case_of_array : T_Tableau ; >=20 > get_l : integer :=3D 1 ; > -- R=F4le d'intervalle dans le tableau , dans la boucle >=20 > c_to_put : integer ; >=20 > nb_lign_to_put : integer :=3D 1 ; >=20 > Begin >=20 > Open > (File =3D> this_file , > Mode =3D> In_file , > Name =3D> "main.adb"); >=20 > un : loop exit when End_Of_File ( this_file ) ; > set_line ( this_file , next_l ) ; >=20 > case_of_array(get_l) :=3D Get_Line( this_file ); >=20 > next_l :=3D next_l + 1 ; > get_l :=3D get_l + 1 ; >=20 > c_to_put :=3D get_l ; > -- compte le nbr de get_line effectu=E9 >=20 > end loop un ; >=20 > Open > (File =3D> f_deux , > Mode =3D> Out_file , > Name =3D> "verify"); >=20 > deux : loop exit when nb_lign_to_put =3D c_to_put ; >=20 > Put_line( f_deux , case_of_array(nb_lign_to_put) ) ; >=20 > nb_lign_to_put :=3D nb_lign_to_put + 1 ; >=20 > end loop deux ; > End main ; It is very inefficient. In fact, the Set_Line (...) can be eliminated. In a= ddition, next_l, c_to_put and nb_lign_to_put variables are not needed. Anh Vo