comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Re-write a file in Ada
Date: Sun, 10 Jan 2016 19:59:06 +0100
Date: 2016-01-10T19:59:06+01:00	[thread overview]
Message-ID: <n6u9h3$hc4$1@dont-email.me> (raw)
In-Reply-To: <888e0bed-6d19-4ab6-84e7-67dd2f227407@googlegroups.com>

On 2016-01-10 17:54, comicfanzine@gmail.com wrote:
> Ok , in others words :
> 
> I want to open the file , copy all the lines in it , then do some change in those lignes ( unbounded_strings ) , and finally paste all in the file ( mode : Out_file ) .
> 
> This is what i meant by " Re-write a file " .
> 
> 
> The error :
> 
> raised ADA.IO_EXCEPTIONS.END_ERROR : a-tigeli.adb:96
> 

Below, you need tocomplement with paramters for
open/create, and declare from_file and to_file

try something like :


--pseudo code

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 Rewrite is
  Buffer : Unbounded_String := Null_Unbounded_String;
begin
  Open (From_file);
  Create(To_File);

  begin
    loop
      Buffer := Get_Line(From_File);
      Put_Line(To_File, Buffer);
    end loop;
  exception
    when End_Error =>
      Close(From_File);
      Close(To_File);
  end;
end Rewrite;



-- 
--
Björn


  reply	other threads:[~2016-01-10 18: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 [this message]
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
replies disabled

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