comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Ada Examples and Problems
Date: Thu, 12 Apr 2001 21:47:09 GMT
Date: 2001-04-12T21:47:09+00:00	[thread overview]
Message-ID: <xnpB6.4761$FY5.344853@www.newsranger.com> (raw)
In-Reply-To: oTmB6.7485$FD1.924788@news6-win.server.ntlworld.com

In article <oTmB6.7485$FD1.924788@news6-win.server.ntlworld.com>, chris.danx
says...
>Ok maybe i'm confused as to what you meant.
>
>I wrote the following
>
>    begin
>        owner_name_type'write (s, item.name);
>        integer'write                   (s, item.age);
>        sex_type'write                (s, item.sex);
>    end  owner_write;
>
>but i get the feeling that's not what you meant.  Is it?

Not quite. Ada allows you to override 'Write and 'Read with your own routines.
Now you can do that, then just write the above. But now you still don't know the
size of all the little 'Writes. However, if you Unchecked_Convert the entire
structure into a stream element array, then pass it into Ada.Streams.Write
directly, then obviously you now know exactly how many stream elements it uses. 

>Even if my read write routines are correct, how can my code adjust
>automatically.  I want to skip records in the stream, to do that i need to

If you do your own conversion to an array of stream elements, rather than
letting Ada do it for you, then calculating the length of the array required is
fairly easy (you'll have to do it to get the unchecked_Conversion to work
anyway). Since you now know that length, you can just increment the file pointer
by that length to skip the entire object in the stream (file).

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  parent reply	other threads:[~2001-04-12 21:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-10 13:38 Ada Examples and Problems chris.danx
2001-04-10 17:53 ` chris.danx
2001-04-10 17:57   ` chris.danx
     [not found] ` <ERFA6.2041$FY5.146015@www.newsranger.com>
2001-04-11  9:51   ` chris.danx
2001-04-11 15:34     ` Ted Dennison
2001-04-11 17:18       ` chris.danx
2001-04-11 17:43         ` chris.danx
2001-04-11 19:01           ` Marc A. Criley
2001-04-11 19:56             ` chris.danx
2001-04-12  1:41               ` tmoran
2001-04-12 15:28         ` Ted Dennison
2001-04-12 18:56           ` chris.danx
2001-04-12 19:01             ` chris.danx
2001-04-12 21:47             ` Ted Dennison [this message]
2001-04-13  8:40               ` chris.danx
2001-04-12  1:41     ` tmoran
2001-04-12 10:15       ` chris.danx
replies disabled

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