comp.lang.ada
 help / color / mirror / Atom feed
* Re-write a file in Ada
@ 2016-01-06 15:55 comicfanzine
  2016-01-07 13:02 ` comicfanzine
                   ` (8 more replies)
  0 siblings, 9 replies; 34+ messages in thread
From: comicfanzine @ 2016-01-06 15:55 UTC (permalink / raw)


Hello everybody ,

Next , a working code which re-write entirely a file .

I would like to modify it , doing the same thing exept that : 

Undounded_strings will be generate every time there is a next line .

Then , several get_line will be done on those strings .

And in final , put those modified strings in the file .


Anyone knows how to code that ?

Here is what i done for now =

with Ada.Text_IO.Unbounded_IO ; use Ada.Text_IO.Unbounded_IO ;
with Ada.Strings.Unbounded ;    use Ada.Strings.Unbounded ;
with Ada.Text_IO ;              use Ada.Text_IO ;
 
Procedure main is
 
  this_file : File_Type ;
 
  copy_file_1 : Unbounded_String ;
  copy_file_in_1 : Unbounded_String ;
 
  next_line : Positive_Count := 1 ;
 
Begin
 
     Open
     (Mode => In_file ,
      File => this_file ,
      Name => "main.adb" ) ;
 
 
     loop
        exit when End_Of_File ( this_file ) ;
 
     Set_Line ( this_file , next_line );
 
     get_line ( this_file , copy_file_in_1 ) ;
 
     Append
     ( Source  => copy_file_1 ,
       New_Item => copy_file_in_1 ) ;
 
      next_line := next_line + 1 ;
 
     end loop ;
 
    Close ( this_file ) ;
 
     Open
     (Mode => Out_file ,
      File => this_file ,
      Name => "main.adb" ) ;
 
     put ( this_file , copy_file_1 ) ;
 
     Close ( this_file ) ;
 
end main ;

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2016-01-21 12:31 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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