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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d142408257dde54c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-30 14:35:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!grolier!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail Reply-To: "Liddle Feesh" From: "Liddle Feesh" Newsgroups: comp.lang.ada References: Subject: Re: Can someone help me understand this queue package? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Sun, 30 Dec 2001 22:28:31 -0000 NNTP-Posting-Host: 213.105.185.39 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 1009751397 213.105.185.39 (Sun, 30 Dec 2001 22:29:57 GMT) NNTP-Posting-Date: Sun, 30 Dec 2001 22:29:57 GMT Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:18402 Date: 2001-12-30T22:28:31+00:00 List-Id: "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