* Opening a File for Appending
@ 1995-01-05 15:44 Thomas Albrecht
1995-01-06 17:26 ` David Weller
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Albrecht @ 1995-01-05 15:44 UTC (permalink / raw)
Does anyone know how to open a text file for appending. I have
checked the Ada Manual in both Ch. 14 (Input/Output) and Ch.13
(system-dependent features) and have been unable to locate it.
Thanks in advance for you help.
-- Tom
========================================================================
== Thomas Albrecht
== Southwest Research Institute
== San Antonio, Texas
== TAlbrecht@swri.edu
========================================================================
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Opening a File for Appending
1995-01-05 15:44 Opening a File for Appending Thomas Albrecht
@ 1995-01-06 17:26 ` David Weller
1995-01-06 23:14 ` Steven B. Opdahl
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: David Weller @ 1995-01-06 17:26 UTC (permalink / raw)
In article <847@trident.datasys.swri.edu>,
Thomas Albrecht <TAlbrecht@SwRI.EDU> wrote:
>Does anyone know how to open a text file for appending. I have
>checked the Ada Manual in both Ch. 14 (Input/Output) and Ch.13
>(system-dependent features) and have been unable to locate it.
>Thanks in advance for you help.
>
Um, in Ada95, one of the file modes is Append_File (for any of Text,
Sequential, Wide, and Stream_IO files).
Appending a file in Ada83 is OS dependent (unless the POSIX binding
supports this -- I'm not sure).
--
Frustrated with C/C++, Pascal, Fortran? Ada95 _might_ be for you!
For all sorts of interesting Ada95 tidbits, run the command:
"finger dweller@starbase.neosoft.com | more" (or e-mail with "finger" as subj.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Opening a File for Appending
1995-01-06 17:26 ` David Weller
@ 1995-01-06 23:14 ` Steven B. Opdahl
1995-01-07 1:28 ` Keith Thompson
1995-01-07 22:23 ` Richard Riehle
2 siblings, 0 replies; 5+ messages in thread
From: Steven B. Opdahl @ 1995-01-06 23:14 UTC (permalink / raw)
In article <3ejufu$g56@Starbase.NeoSoft.COM>,
David Weller <dweller@Starbase.NeoSoft.COM> wrote:
:
:Um, in Ada95, one of the file modes is Append_File (for any of Text,
:Sequential, Wide, and Stream_IO files).
:
:Appending a file in Ada83 is OS dependent (unless the POSIX binding
:supports this -- I'm not sure).
POSIX_IO supports this. You need to add Append to the Open_Option_Set
before doing an Open, Open_Or_Create, or Set_File_Control.
Steve Opdahl
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Opening a File for Appending
1995-01-06 17:26 ` David Weller
1995-01-06 23:14 ` Steven B. Opdahl
@ 1995-01-07 1:28 ` Keith Thompson
1995-01-07 22:23 ` Richard Riehle
2 siblings, 0 replies; 5+ messages in thread
From: Keith Thompson @ 1995-01-07 1:28 UTC (permalink / raw)
In <3ejufu$g56@Starbase.NeoSoft.COM> dweller@Starbase.NeoSoft.COM (David Weller) writes:
> Um, in Ada95, one of the file modes is Append_File (for any of Text,
> Sequential, Wide, and Stream_IO files).
>
> Appending a file in Ada83 is OS dependent (unless the POSIX binding
> supports this -- I'm not sure).
Yes it does, via the Form parameter of Text_IO.Open.
Here's a test/demo program; you can compile and execute it to find out
whether your implementation supports POSIX-style appending to a text file.
Note that it isn't necessary to explicitly "with" any POSIX packages;
POSIX specifies this behavior for the LRM-defined Text_IO package.
with Text_IO;
procedure Append_Test is
File: Text_IO.File_Type;
File_Name: constant String := "append.txt";
Line1: constant String := "First line";
Line2: constant String := "Second line";
Ok: Boolean := True;
begin
Text_IO.Create( File => File,
Mode => Text_IO.Out_File,
Name => File_Name );
Text_IO.Put_Line(File, Line1);
Text_IO.Close(File);
Text_IO.Open( File => File,
Mode => Text_IO.Out_File,
Name => File_Name,
Form => "Append => True" );
Text_IO.Put_Line(File, Line2);
Text_IO.Close(File);
declare
S: String(1 .. 100);
Last: Natural;
begin
Text_IO.Open( File => File,
Mode => Text_IO.In_File,
Name => File_Name );
Text_IO.Get_Line(File, S, Last);
if S(S'First .. Last) /= Line1 or Text_IO.End_Of_File(File) then
Ok := False;
else
Text_IO.Get_Line(File, S, Last);
if S(S'First .. Last) /= Line2 then
Ok := False;
end if;
end if;
exception
when others =>
Ok := False;
end;
begin
Text_IO.Delete( File );
exception
when others =>
Ok := False;
end;
if Ok then
Text_IO.Put_Line("This implementation supports POSIX-style");
Text_IO.Put_Line("appending to a text file via the Form parameter.");
else
Text_IO.Put_Line("This implementation does not support POSIX-style");
Text_IO.Put_Line("appending to a text file via the Form parameter,");
Text_IO.Put_Line("or some other problem occurred.");
end if;
end Append_Test;
--
Keith Thompson (The_Other_Keith) kst@thomsoft.com (kst@alsys.com still works)
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
When you're a nail, every problem looks like a hammer.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Opening a File for Appending
1995-01-06 17:26 ` David Weller
1995-01-06 23:14 ` Steven B. Opdahl
1995-01-07 1:28 ` Keith Thompson
@ 1995-01-07 22:23 ` Richard Riehle
2 siblings, 0 replies; 5+ messages in thread
From: Richard Riehle @ 1995-01-07 22:23 UTC (permalink / raw)
In a>In article <847@trident.datasys.swri.edu>,
>Thomas Albrecht <TAlbrecht@SwRI.EDU> wrote:
>>Does anyone know how to open a text file for appending. I have
>>checked the Ada Manual in both Ch. 14 (Input/Output) and Ch.13
>>(system-dependent features) and have been unable to locate it.
>>Thanks in advance for you help.
>>
>
Thomas -
The good people at Alsys have provided a parameter for the
formal argument, FORM, in the Text_IO.OPEN procedure that
enables opening a file in APPEND mode.
My VADS compiler manual does not indicate how to do this, but
I may have an out-of-date VADS manual.
In Ada 83/87 this is implementation-dependent. Thank you to
designers of the new Ada standard for including an append
capability in Ada.
Richard Riehle
email: adaworks@netcom.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1995-01-07 22:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-01-05 15:44 Opening a File for Appending Thomas Albrecht
1995-01-06 17:26 ` David Weller
1995-01-06 23:14 ` Steven B. Opdahl
1995-01-07 1:28 ` Keith Thompson
1995-01-07 22:23 ` Richard Riehle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox