comp.lang.ada
 help / color / mirror / Atom feed
* Beginner Need help !
@ 1996-04-22  0:00 Andr�
  1996-04-23  0:00 ` Michael Levasseur
  1996-04-23  0:00 ` Joerg Rodemann
  0 siblings, 2 replies; 4+ messages in thread
From: Andr� @ 1996-04-22  0:00 UTC (permalink / raw)


Hello Ada programers,

A beginner need help !
I want to write (in text mode) at the end of a file.

I tought using Text_IO.Open(...) with an existing file opened in
OUT_FILE mode, the result of the following code should append to
the file ...
But in fact, the original file is replaced with the new one !

What is wrong with this code ???

Thank you (excuse my english expression),
Andr� Baril  <bbp_abar@gig.net>


With Text_IO;
Procedure FileTest IS
Package IO_INT IS NEW Text_IO.Integer_IO(Num => Integer);

File_A : Text_IO.File_Type;
Line   : String(1..6) := "Line :";
Number : Natural;

Begin
   -- In this exemple the file, "b:\file_a.txt" should exit ...
   Text_IO.Open(File_A, Text_IO.Out_File, "b:\File_A.txt");

   FOR i IN 1..10 LOOP
      Text_IO.Put(File_A, Line);
      IO_INT.Put(File_A, i, 4);
      Text_IO.New_Line(File_A);
   END LOOP;

   Text_IO.Close(File_A);
End FileTest;




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

* Re: Beginner Need help !
  1996-04-22  0:00 Beginner Need help ! Andr�
  1996-04-23  0:00 ` Michael Levasseur
@ 1996-04-23  0:00 ` Joerg Rodemann
  1 sibling, 0 replies; 4+ messages in thread
From: Joerg Rodemann @ 1996-04-23  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

Hello!

Andr� (bbp_abar@gig.net) wrote:
> Hello Ada programers,

> A beginner need help !
> I want to write (in text mode) at the end of a file.

> I tought using Text_IO.Open(...) with an existing file opened in
> OUT_FILE mode, the result of the following code should append to
> the file ...
> But in fact, the original file is replaced with the new one !

Sure as is requested by the standard. Replace Out_File by Append_File and
everthing should be ok.

Greetings

George




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

* Re: Beginner Need help !
  1996-04-22  0:00 Beginner Need help ! Andr�
@ 1996-04-23  0:00 ` Michael Levasseur
  1996-04-23  0:00   ` Ledru#m#_Pascal
  1996-04-23  0:00 ` Joerg Rodemann
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Levasseur @ 1996-04-23  0:00 UTC (permalink / raw)


I'm not sure but I think the file needs to be opened with the
file mode "in out" and then goto the EOF then perform a write.





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

* Re: Beginner Need help !
  1996-04-23  0:00 ` Michael Levasseur
@ 1996-04-23  0:00   ` Ledru#m#_Pascal
  0 siblings, 0 replies; 4+ messages in thread
From: Ledru#m#_Pascal @ 1996-04-23  0:00 UTC (permalink / raw)


Just use the mode Append_File (which does not exist in Ada83 by the 
way!)

with Text_IO;
procedure TestFile2 is
  package IO_Int is new Text_IO.Integer_IO( Num => Integer);
  use IO_Int;
  File_A : Text_IO.FILE_TYPE;
begin
  -- we assume the file always exists here!
  Text_IO.Open
    ( File => File_A,
      Mode => Text_IO.Append_File,
      Name => "File_A" );

  for I in 1 .. 10 loop
    Text_IO.Put(File_A, "Line : ");
    IO_Int.Put( File_A, i, 4);
    Text_IO.New_Line(File_A);
  end loop;

  Text_IO.Close( File_A );
end;




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

end of thread, other threads:[~1996-04-23  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-22  0:00 Beginner Need help ! Andr�
1996-04-23  0:00 ` Michael Levasseur
1996-04-23  0:00   ` Ledru#m#_Pascal
1996-04-23  0:00 ` Joerg Rodemann

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