comp.lang.ada
 help / color / mirror / Atom feed
* Queue System -- record type has changed?
@ 1997-10-07  0:00 Nathan J
  1997-10-07  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan J @ 1997-10-07  0:00 UTC (permalink / raw)



I am doing an assignment in Ada (my first) and need some help with data
structues. (Before you ask, I don't need a code listing, I need some
(simple) help telling me what could be wrong). Could you please help?

If this helps any, I am using GNAT ADA 3.07 to code and compile it (as
far as I can tell)

Using a predefined Queue structure, I enqueue a few dummy records of
type Record_Type (a few strings and integers), containing a couple of
integers and floating point values. I then ask to call a procedure
"Display" whose spec is:

	Generic
	with procedure put_object(object : object_type);
	procedure display(the_queue : queue);
	-- results    : Displays the queue of objects.

The body contains a few while and if statements but the bit I am
concentrating on is:

	put_object(the_queue.objects(i));

Where the_queue.objects(i) is number (i) of a for loop, and
the_queue.objects is an array of record_type, which was added to when I
enqueued the dummy records. 

I added a spec for put_object: (Fnord, by the way, means nothing)

	procedure put_object(object : object_type);
	-- fnord

And the body:

	procedure put_object(object : object_type) is
	
	package integer_io is new text_io.integer_io(integer); --
Instantiations
	package float_io is new text_io.float_io(float);       -- For I/O
	use float_io;
	use integer_io;
	
	begin
	put (object.part_one);
	
	end put_object;						 
	
Where part_one is the name of the first field in the Record_Type that I
defined, of type integer.

Because this came up with some error I couldn't understand (just like
most of them), I commented out the "Generic" and "With procedure &c."
lines from the display spec, and re-compiled it.

It refuses to recognise object.part_one, because:

139. put (object.part_one);
          |
     >>> invalid prefix in selected component "temp_record"

I can't understand this. As far as I can tell, the structure should be
exactly the same as Record_type...

Finally, if I delete the "Put (object.part_one);" line from the code and
insert:

	Put ("Hi");

It compiles, links, and when I try to generate an EXE file, it kicks me
into GDB (?) after creating the EXE, and if I run either the EXE file,
or the COF through GDB, if prints "Hi" three times (because I enqueued 3
records), and then exits normally (Checked with a "Put ("Exited
normally")" just before the end statement)

Could someone please help me here?

Thanks in advance,
Nathan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-10-07  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-07  0:00 Queue System -- record type has changed? Nathan J
1997-10-07  0:00 ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox