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 08:36:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.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: Wed, 11 Apr 2001 15:34:43 GMT NNTP-Posting-Host: 209.208.22.130 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 987003283 209.208.22.130 (Wed, 11 Apr 2001 11:34:43 EDT) NNTP-Posting-Date: Wed, 11 Apr 2001 11:34:43 EDT Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:6766 Date: 2001-04-11T15:34:43+00:00 List-Id: 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? There's no LRM guarantee for how many storage units that the compiler will decide to use for each Dog_Type. 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). 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. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com