[comp.lang.ada] Append files using TEXT_IO

lehman@asd.span (Richard A Lehman, DMSTB) (06/12/90)

Subject: Appending to files using TEXT_IO...

We have a requirement to determine if a file exists within
the current users directory.  If the file does not exist
we create if and log network transactions to it.

However if the file does exist we wish to log network
transactions to the end of the existing file.  Using TEXT_IO
there are a number of procedures which manipulate files
such as RESET, SET_LINE_LENGTH, SKIP_LINE, etc.  There
is no straight forwared procedure for OPEN_APPEND.  

We are seeking out projects which have solved this problem
before and come up with a clean way of opening a file
within the TEXT_IO package and appending to the end of it.

Thanks in advance,

Richard A Lehman

Lockheed Engineering & Science Co.
2400 NASA Road 1
Houston, TX   77058
713.333.7074

lehman%asd.span@jpl-vlsi.arpa

stt@inmet.inmet.com (06/13/90)

Re: Appending to a text file.

Leaving out "append" was probably a bug in Ada83.
Many compilers have provided a mechanism for open-with-append,
by an appropriate FORM string.  Check out the Appendix F of
your favorite compiler.

If all else fails, try pragma Interface to gain access to
the Unix Seek and Write.  You should be able to prepare
a string for output using the Text_IO.Put(TO: out String; ...),
and then pass its address and length directly to Unix Write.

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

falis@ajpo.sei.cmu.edu (Edward Falis) (06/14/90)

Doing things like opening a file in append mode, defining record sizes for
I/O etc are typically handled via the "form" parameter, and are vendor
specific. Check out Appendix F for the compiler you're using. The answer
(non-portable) may be there. - Ed Falis, Alsys