comp.lang.ada
 help / color / mirror / Atom feed
* File I/O Question
@ 1990-04-11 14:03 Dick Koolish
  1990-04-12 14:10 ` stt
  0 siblings, 1 reply; 2+ messages in thread
From: Dick Koolish @ 1990-04-11 14:03 UTC (permalink / raw)




I need to read some existing data files from an Ada program.
The files have a header block followed by data records.
Different files have different data record sizes.  The size and
number of data records is specified in the header block.
I also need to be able to read the data starting at any record
and when I get to the physical end of file to wrap around to the
start of the data again.

The two questions are how to read two different kinds of records
out of a file and how to do this if you don't know the size of
one of the records until you open the file and read the header.

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

* Re: File I/O Question
  1990-04-11 14:03 File I/O Question Dick Koolish
@ 1990-04-12 14:10 ` stt
  0 siblings, 0 replies; 2+ messages in thread
From: stt @ 1990-04-12 14:10 UTC (permalink / raw)



Regarding reading files with multiple record types:

The language-defined I/O packages don't handle this
kind of file, at least not without standing on your head.
However, it seems to be a little known fact that it is
permissible to write your *own* I/O packages!  

I am only being a little facetious here.  It is important to realize
that the Ada Reference Manual provides only a starting point for I/O services.
It does not define any standard interface to the underlying
O/S I/O services, though most Ada vendors provide such packages.
Even if your vendor doesn't provide such an I/O package, it
is almost always possible to use pragma Interface to Assembler
or C to accomplish the job.  By the way, the Posix/Ada folks are making good
progress on standardizing an Ada interface to Posix (Unix) I/O services.

Perhaps Ada9X will try to directly address some of these very real problems,
but alternatively, it may instead focus on providing the primitives
(refinements to 'ADDRESS, 'SIZE, and unchecked-conversion) so that
application-specific I/O packages will be easier to write in a portable,
compiler-independent way.  In any case, judicious use of 'ADDRESS, 'SIZE,
and Unchecked_Conversion can go a long way already toward easing
the solution to your I/O problems.

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

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

end of thread, other threads:[~1990-04-12 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-04-11 14:03 File I/O Question Dick Koolish
1990-04-12 14:10 ` stt

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