comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Ada Examples and Problems
Date: Wed, 11 Apr 2001 15:34:43 GMT
Date: 2001-04-11T15:34:43+00:00	[thread overview]
Message-ID: <nQ_A6.3185$FY5.218929@www.newsranger.com> (raw)
In-Reply-To: DOVA6.3493$FD1.403553@news6-win.server.ntlworld.com

In article <DOVA6.3493$FD1.403553@news6-win.server.ntlworld.com>, 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



  reply	other threads:[~2001-04-11 15:34 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 [this message]
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
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