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-11 10:24:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!grolier!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news2-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: Subject: Re: Ada Examples and Problems X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Wed, 11 Apr 2001 18:18:34 +0100 NNTP-Posting-Host: 62.252.144.70 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 987009496 62.252.144.70 (Wed, 11 Apr 2001 18:18:16 BST) NNTP-Posting-Date: Wed, 11 Apr 2001 18:18:16 BST Organization: ntlworld News Service Xref: supernews.google.com comp.lang.ada:6773 Date: 2001-04-11T18:18:34+01:00 List-Id: "Ted Dennison" wrote in message news:nQ_A6.3185$FY5.218929@www.newsranger.com... > In article , chris.danx > says... > > > > > >The program appears to read all the owners from the file. When it goes to > >output them on the screen it print's the first owner ok, but then hit's out > >with a constraint error on the second. > > > >The problem definitely comes from the way it reads the file's. I've tested > >the onwer_type completely. It works on a sequential read but not on a > >non-sequential read. > > > >It should read the first record(owner), skip one(dog), read(owner)... > > .. > > while count <= 5 and not end_of_file(file) loop > > owners.owner_type'read(strm, the_owners(count)); > > set_index(file, index(file) + positive_count(offset+1)); > > ada.integer_text_io.put(integer(index(file))); > > ada.text_io.new_line; > > count := count + 1; > > end loop; > > end read_owners; > > Ahhhh. You are using indexing to move the file pointer around. You do of course > realize that this is completely non-portable, unless you wrote your own > Dog_Type'Write and Dog_Type'Read routines? I did do this. > There's no LRM guarantee for how many > storage units that the compiler will decide to use for each Dog_Type. That's not suprising but it is a bugger. > In fact, my suspicion would be that it indeed does not use the same number of > storage units as you think it does for Dog_Type (1, if I read your code right). Ok. I think i'll try working out the size (should be 30+4+4+size of enum sex_type). > The best way to check is to use "od" to view the data in the file. If you are > using Windoze instead of Unix, go get Cygwin (see my website for the URL). It > should have a copy of od in it. A wild guess would be that your system uses a > byte for a storage unit, and Dog_Type is 4 of them (assuming its some > kind of > enumeration or integer). But I'd check it out for sure. I'll take a look and see. Thanks for the info. If what you've said is correct how then can i write the code so that i don't need to count each individual entry and hardwire it into the program. It'd be much nicer if when i changed the types, i could just recompile the modules without changing the values for the sizes of records. I should go to eat something, that was totally incomprehensible. Cheers, Chris