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 02:57:30 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!newsfeed.berkeley.edu!ucberkeley!dispose.news.demon.net!demon!newspeer.clara.net!news.clara.net!news5-gui.server.ntli.net!ntli.net!news6-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 10:51:53 +0100 NNTP-Posting-Host: 62.252.137.254 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 986982691 62.252.137.254 (Wed, 11 Apr 2001 10:51:31 BST) NNTP-Posting-Date: Wed, 11 Apr 2001 10:51:31 BST Organization: ntlworld News Service Xref: supernews.google.com comp.lang.ada:6743 Date: 2001-04-11T10:51:53+01:00 List-Id: > >Basically the program should read in the owners from a file, then the dogs. > >The file is arranged owner, dog, owner, dog... > So what *is* it doing? I'm a complete numpty! Sorry! 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)... This is what i thought would achieve it. procedure read_owners (the_owners : out owner_array_type; file : in out file_type) is count : natural := 1; strm : stream_access; offset : positive; begin strm := stream(file); -- get a stream from a file; set_index(file, 1); offset := (doggies.dog_type'size / 8); -- calculate the offset of next 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; I reckon that it has something to do with the records size. I'm not sure what though. Is the size of the record the same as the number of bytes written per record? Maybe this is it. This is my first endevour into the world of non-sequential streams and i'm still trying to get this right. I just thought of something, I've tried adding 1, not adding 1, but not taking 1 away. I'll try that now! Regards, Chris