From: "Liddle Feesh" <no_see_reply_address@spam.com>
Subject: Re: Can someone help me understand this queue package?
Date: Sun, 30 Dec 2001 22:28:31 -0000
Date: 2001-12-30T22:28:31+00:00 [thread overview]
Message-ID: <FzMX7.13085$ll6.1890252@news6-win.server.ntlworld.com> (raw)
In-Reply-To: mailman.1009717862.32290.comp.lang.ada@ada.eu.org
"Michal Nowak" wrote:
> Look at the line where you defined access type to node (you even marked
> it with comment).
>
> You had errors, because you did not declared a variable of this type.
> Try now:
>
> > procedure add (n: in integer; q: in out queue) is
> New_Item : Link; --declare a variable of link type
> > begin
> New_Item := new node;
>
> --now set appriopriate fields in New_Item,
> --set Head and Tail for queue, and should be OK.
No - after adding those lines the package spec no longer compiles. I don't
understand why you want to add those lines in there.
Errors generated are : "Direct Name, Link, is not visable, Ignoring future
references", and "Parse error expecting declaration, got BEGIN,
Skipping..."
[snip]
> >How do I create a new node, and point the 'next' value to the 'value' of
> >the
> >next node? I know how this is done on paper...
>
> link is access type to node. So speaking in C language, it should point
> to element of type node. In your queue you have components Head and Tail,
> that should point to first and last element in the queue. They are of the
> same type as New_Item is. So:
>
> New_Item.Next := Tail; --next points you to element, which is still
> --considered to be on the end of the queue
> Tail := New_Item; --now the last element is the one you created.
Link is access type to node - okay
Should point to element of type node - okay (HOW is this done?)
Queue is made up of a Head, and the remainder(Queue). Tail in this case will
point to the last element, although this is not strictly correct.
New_Item.Next := Tail -- Next is the pointer to the value section of the
next element (node). I see - you assign "Tail" to the New_Item's NEXT
pointer. Excellent. Thanks.
Tail := New_Item -- Now, this I don't understand. You are assigning a new
element to the tail?
----
What I don't get - from the original post, is what is the syntax for
manipulating this queue stuff, and where do I put it? I'm completely stuck
when it comes to these three files - 1. Test Harness, 2. Package Body, and
3. Package Spec.
Okay - so I can call procedures and functions in the spec from the from the
test harness, but what do I do? I mean - I've added the line
add;
into a main menu in the test harness - to call the procedure 'add' - which
currrently has just a 'null;' in it. It doesn't do anything!
Thanks for your help though,
Mike
next prev parent reply other threads:[~2001-12-30 22:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-28 17:14 Can someone help me understand this queue package? Liddle Feesh
2001-12-28 18:16 ` Michal Nowak
2001-12-28 22:57 ` Liddle Feesh
2001-12-29 11:35 ` Michal Nowak
2001-12-29 19:37 ` Liddle Feesh
2001-12-29 20:05 ` Michal Nowak
2001-12-29 20:44 ` Liddle Feesh
2001-12-29 22:02 ` Liddle Feesh
2001-12-30 13:14 ` Michal Nowak
2001-12-30 22:28 ` Liddle Feesh [this message]
2001-12-31 10:32 ` Michal Nowak
2001-12-29 17:13 ` Liddle Feesh
2001-12-29 18:42 ` martin.m.dowie
2001-12-29 19:09 ` Liddle Feesh
2001-12-29 17:13 ` Liddle Feesh
2001-12-29 17:13 ` Liddle Feesh
2001-12-29 17:14 ` Liddle Feesh
2001-12-29 17:39 ` Liddle Feesh
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox