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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,225946aa0d08aebc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-06 11:51:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!diablo.theplanet.net!btnet-peer!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news2-win.server.ntlworld.com.POSTED!not-for-mail From: "Phoenix." Newsgroups: comp.lang.ada Subject: Re: Why can't i get an EXE! 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: <8Q1_7.2291$6q2.727350@news2-win.server.ntlworld.com> Date: Sun, 6 Jan 2002 19:45:02 -0000 NNTP-Posting-Host: 62.252.9.7 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 1010346372 62.252.9.7 (Sun, 06 Jan 2002 19:46:12 GMT) NNTP-Posting-Date: Sun, 06 Jan 2002 19:46:12 GMT Organization: ntlworld News Service Xref: archiver1.google.com comp.lang.ada:18588 Date: 2002-01-06T19:45:02+00:00 List-Id: Tankyou very much for your assistance with my program. Your advise has solved my primary problem. However I appear to have a new problem. My program now runs however it doesn't perform it's desired task. Which is to allow the user to add and remove items from a queue and also to show what is in the queue. This is where my problem occured when I was trying to show what is stored within the queue. The problem is that as soon as the procedure ends, it appears to clear what is stored within the que. Therefore I think the problem is that the variables are not declared globally, and are local to each procedure, and thus I was wondering how I declare them Globally if that is the problem. However if it is not the problem I was wondering what the problem is. >>BEGIN QUE.ADS package Que is Empty_Queue : exception; type Queue is array(1..500) of Integer; Q : Queue; Qs : Queue; Tail : Integer := 0; Tails : Integer := 0; Head : Integer := 1; Heads : Integer := 1; Count : Integer := 0; N : Integer; A : Integer; procedure Initialiser(Q: in out Queue; Head: in out Integer; Tail: in out Integer); procedure Add(Q: in out Queue; Head: in out Integer; Tail: in out Integer); procedure Remove(Q: in out Queue; Head: in out Integer; Tail: in out Integer); procedure Show(Q: in out Queue; Head: in out Integer; Tail: in out Integer); end Que; <>BEGIN QUE.ADB with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io; with Text_Io; use Text_Io; package body Que is procedure Initialiser(Q: in out Queue; Head: in out Integer; Tail: in out Integer) is begin Tail := 0; Head := 1; end Initialiser; procedure Add(Q: in out Queue; Head: in out Integer; Tail: in out Integer) is begin Put_Line("Please enter an integer "); Get(N); Tail := Tail+1; Q(Tail) := N; -- call proc show here -- Proc SHOW for Count in Tail..Head loop A := Q(Count); Put(A); end loop; -- END PROC SHOW end Add; procedure Remove(Q: in out Queue; Head: in out Integer; Tail: in out Integer) is begin if Head < Tail then --put_line("Queue is currently empty"); raise Empty_Queue; else Head := Head + 1; end if; --call proc show here exception when Empty_Queue=> Skip_Line; Put_Line("The queue is currently empty"); New_Line; end Remove; procedure Show(Q: in out Queue; Head: in out Integer; Tail: in out Integer) is A : integer; begin put_line("This is your queue: - "); if Head > Tail then --put_line("Queue is currently empty"); raise Empty_Queue; else for Count in Head..Tail loop A := Q(count); Put(A); end loop; end if; exception when Empty_Queue => Skip_Line; Put_Line("The queue is currently empty"); New_Line; end Show; end Que; <>BEGIN MAIN.ADB with Que; use Que; with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io; procedure Main is begin loop Initialiser(Q, Head, Tail); New_Line; Put_Line("****************************"); Put_Line(" 1). Add to queue"); Put_Line(" 2). remove to queue"); Put_Line(" 3). Show Queue"); Put_Line(" 4). Quit queue program"); Put_Line("****************************"); New_Line; Get(A); case A is --Execute menu option depending on A's value when 1 => Add(Q, Head, Tail); when 2 => Remove(Q, Head, Tail); when 3 => Show(Q, Head, Tail); when 4 => exit; when others => Put_Line("Sorry incorrect entry please retry"); end case; end loop; end Main; <