comp.lang.ada
 help / color / mirror / Atom feed
From: Anh Vo <anhvofrcaus@gmail.com>
Subject: Re: Re-write a file in Ada
Date: Sun, 10 Jan 2016 17:59:07 -0800 (PST)
Date: 2016-01-10T17:59:07-08:00	[thread overview]
Message-ID: <e112977e-a114-478f-a0bd-b8d19e64f9b7@googlegroups.com> (raw)
In-Reply-To: <e1a2eaab-9082-4379-b5d4-0f82a6dcaa9a@googlegroups.com>

On Sunday, January 10, 2016 at 2:57:42 PM UTC-8, comicf...@gmail.com wrote:
> Thanks björn lundin and the others !
> 
> I finally suceed :
> 
> 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 ;
> 
> Procedure main is
> 
>   next_l : Positive_Count := 1 ;
> 
>   this_file : File_type ;
> 
>   f_deux : File_type ;
> 
>   Type T_Tableau is array( 1 .. 1_000 ) of unbounded_string ;
> 
>   case_of_array : T_Tableau ;
> 
>   get_l : integer := 1 ;
>   -- Rôle d'intervalle dans le tableau , dans la boucle
> 
>   c_to_put : integer ;
> 
>   nb_lign_to_put : integer := 1 ;
> 
> Begin
> 
> 	Open
>      (File => this_file ,
>       Mode => In_file ,
>       Name => "main.adb");
> 
>     un : loop exit when End_Of_File ( this_file ) ;
> 	    set_line ( this_file , next_l ) ;
> 
> 	    case_of_array(get_l) := Get_Line( this_file );
> 
> 		next_l := next_l + 1 ;
> 		get_l := get_l + 1 ;
> 
> 		 c_to_put := get_l ;
> 	    -- compte le nbr de get_line effectué
> 
>    end loop un ;
> 
>       Open
>      (File => f_deux ,
>       Mode => Out_file ,
>       Name => "verify");
> 
>     deux : loop exit when nb_lign_to_put = c_to_put ;
> 
>      Put_line( f_deux , case_of_array(nb_lign_to_put) ) ;
> 
>      nb_lign_to_put := nb_lign_to_put + 1 ;
> 
>    end loop deux ;
> End main ;

It is very inefficient. In fact, the Set_Line (...) can be eliminated. In addition, next_l, c_to_put and nb_lign_to_put variables are not needed.

Anh Vo


  reply	other threads:[~2016-01-11  1:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 15:55 Re-write a file in Ada comicfanzine
2016-01-07 13:02 ` comicfanzine
2016-01-08 20:35 ` comicfanzine
2016-01-09  9:50   ` Brian Drummond
2016-01-08 21:22 ` Randy Brukardt
2016-01-08 22:08   ` Anh Vo
2016-01-10 16:54 ` comicfanzine
2016-01-10 18:59   ` Björn Lundin
2016-01-11 17:16   ` Brian Drummond
2016-01-18 15:05     ` gautier_niouzes
2016-01-19 12:24       ` Brian Drummond
2016-01-19 16:52         ` gautier_niouzes
2016-01-21 12:26           ` Brian Drummond
2016-01-10 22:57 ` comicfanzine
2016-01-11  1:59   ` Anh Vo [this message]
2016-01-11 10:09   ` Björn Lundin
2016-01-18  0:22 ` comicfanzine
2016-01-18  9:50   ` AdaMagica
2016-01-18 17:27     ` Björn Lundin
2016-01-18 11:52   ` Brian Drummond
2016-01-18 17:30   ` Björn Lundin
2016-01-18 17:25 ` comicfanzine
2016-01-18 17:49   ` J-P. Rosen
2016-01-18 18:37   ` Simon Wright
2016-01-19 12:33   ` Brian Drummond
2016-01-19 14:40     ` Simon Wright
2016-01-21 12:31       ` Brian Drummond
2016-01-19 12:04 ` comicfanzine
2016-01-19 14:29   ` Anh Vo
2016-01-19 14:35     ` Simon Wright
2016-01-19 16:54       ` Jeffrey R. Carter
2016-01-19 17:32         ` Anh Vo
2016-01-19 16:53   ` Stephen Davies
2016-01-20  1:12 ` comicfanzine
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox