comp.lang.ada
 help / color / mirror / Atom feed
* Multiple instantiation of Ada.Direct_IO
@ 1998-01-28  0:00 Blake Weston
  1998-01-28  0:00 ` Matthew Heaney
  1998-02-01  0:00 ` Robert Dewar
  0 siblings, 2 replies; 4+ messages in thread
From: Blake Weston @ 1998-01-28  0:00 UTC (permalink / raw)



Hi there,

I have a bit of a problem. Basically I am using Ada.Direct_IO to read /
write to a file. The problem being I wish to write records of differing
types to the file, without closing the file and re-opening it.

Ada 95 will not even let me open the same file as two different file_type
variables as this creates a Use Exception error.

Can anybody help?

Thanks

Blake






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

* Re: Multiple instantiation of Ada.Direct_IO
  1998-01-28  0:00 Multiple instantiation of Ada.Direct_IO Blake Weston
@ 1998-01-28  0:00 ` Matthew Heaney
  1998-01-29  0:00   ` Nick Roberts
  1998-02-01  0:00 ` Robert Dewar
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Heaney @ 1998-01-28  0:00 UTC (permalink / raw)



In article <886003669.3982.0.nnrp-02.9e98a25e@news.demon.co.uk>, "Blake
Weston" <blake@dedlock.demon.co.uk> wrote:

>Hi there,
>
>I have a bit of a problem. Basically I am using Ada.Direct_IO to read /
>write to a file. The problem being I wish to write records of differing
>types to the file, without closing the file and re-opening it.
>
>Ada 95 will not even let me open the same file as two different file_type
>variables as this creates a Use Exception error.
>
>Can anybody help?

It sounds like you want to perform heterogeneous I/O.  Direct_IO is for
homogeneous I/O.  Try Ada.Stream_I/O instead.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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

* Re: Multiple instantiation of Ada.Direct_IO
  1998-01-28  0:00 ` Matthew Heaney
@ 1998-01-29  0:00   ` Nick Roberts
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 1998-01-29  0:00 UTC (permalink / raw)



Alternatively, I think (no doubt someone will swiftly correct me if I'm
wrong :-) you can get the effect you require by making the record type
discriminated, with a default for each discriminant (so that it is a
'definite' type).

The disadvantage of this method is that, in all likelihood, each record
written in the file will be the size of the biggest possible variant,
regardless of which variant is actually written (so there could be a lot of
wasted space).  You may or may not consider this to be a serious problem. 
Personally, I would not!

-- 

== Nick Roberts ================================================
== Croydon, UK                       ===========================
==                                              ================
== Proprietor, ThoughtWing Software                   ==========
== Independent Software Development Consultant            ======
== Nick.Roberts@dial.pipex.com                              ====
== Voicemail & Fax +44 181-405 1124                          ===
==                                                            ==
==           I live not in myself, but I become               ==
===          Portion of that around me; and to me             ==
====         High mountains are a feeling, but the hum        ==
=======      Of human cities torture.
===========                             -- Byron [Childe Harold]


Matthew Heaney <mheaney@ni.net> wrote in article
<mheaney-ya023680002801980909240001@news.ni.net>...
> In article <886003669.3982.0.nnrp-02.9e98a25e@news.demon.co.uk>, "Blake
> Weston" <blake@dedlock.demon.co.uk> wrote:
> 
> >Hi there,
> >
> >I have a bit of a problem. Basically I am using Ada.Direct_IO to read /
> >write to a file. The problem being I wish to write records of differing
> >types to the file, without closing the file and re-opening it.
> >
> >Ada 95 will not even let me open the same file as two different
file_type
> >variables as this creates a Use Exception error.
> >
> >Can anybody help?
> 
> It sounds like you want to perform heterogeneous I/O.  Direct_IO is for
> homogeneous I/O.  Try Ada.Stream_I/O instead.
> 
> --------------------------------------------------------------------
> Matthew Heaney
> Software Development Consultant
> <mailto:matthew_heaney@acm.org>
> (818) 985-1271
> 




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

* Re: Multiple instantiation of Ada.Direct_IO
  1998-01-28  0:00 Multiple instantiation of Ada.Direct_IO Blake Weston
  1998-01-28  0:00 ` Matthew Heaney
@ 1998-02-01  0:00 ` Robert Dewar
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1998-02-01  0:00 UTC (permalink / raw)



Blake asks

<<I have a bit of a problem. Basically I am using Ada.Direct_IO to read /
write to a file. The problem being I wish to write records of differing
types to the file, without closing the file and re-opening it.

Ada 95 will not even let me open the same file as two different file_type
variables as this creates a Use Exception error.

Can anybody help?

Thanks

Blake
>>


GNAT fully implements file sharing, but there is a penalty involved in
the use of this feature -- you have to read the section of the manual
on file sharing, and I understand that this is too much of a burden for
many people :-)

to be fair, any approach using file sharing is NOT necessarily portable,
which is why GNAT does not allow it by default!





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

end of thread, other threads:[~1998-02-01  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-28  0:00 Multiple instantiation of Ada.Direct_IO Blake Weston
1998-01-28  0:00 ` Matthew Heaney
1998-01-29  0:00   ` Nick Roberts
1998-02-01  0:00 ` Robert Dewar

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