From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ae40b60d59bcdc4b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-12 14:51:58 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!falcon.america.net!sunqbc.risq.qc.ca!headwall.stanford.edu!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: Subject: Re: Ada Examples and Problems Message-ID: Date: Thu, 12 Apr 2001 21:47:09 GMT NNTP-Posting-Host: 209.208.22.130 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 987112029 209.208.22.130 (Thu, 12 Apr 2001 17:47:09 EDT) NNTP-Posting-Date: Thu, 12 Apr 2001 17:47:09 EDT Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:6842 Date: 2001-04-12T21:47:09+00:00 List-Id: In article , 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