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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5355421156b0daa1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-08 02:30:39 PST From: Stewart Newsgroups: comp.lang.ada Subject: Re: Data_Error - Where in this code? Date: Wed, 08 Aug 2001 10:31:22 +0100 Message-ID: References: <1qstmt4hiaiutibe0jies4j0v04ll7mahs@4ax.com> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: host213-123-68-208.dialup.lineone.co.uk X-Trace: 8 Aug 2001 10:30:37 +0100, host213-123-68-208.dialup.lineone.co.uk Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!demon!mk-nntp-1.news.uk.worldonline.com!host213-123-68-208.dialup.lineone.co.uk Xref: archiver1.google.com comp.lang.ada:11590 Date: 2001-08-08T10:31:22+01:00 List-Id: On Mon, 06 Aug 2001 20:47:41 +0100, Stewart wrote: Hi, I still get the Max_Size is not declared, but it is not defined until the variable for the input is obtained. If I put a value in Max_Size I get the constraint_error for the value declared. It now functions as required in both Win98/Dos and Linux. Gnat 3.13. I just have to glue it to the load procedure now. Thanks Stewart >-- Menu commands -- >-- 8 Aug working properly -- > > with Ada.Text_Io; > use Ada.Text_Io; > procedure Menu is > > type Edge_Cost is new Integer range 1 .. 999; > package Cost_InOut is new Integer_Io(Edge_Cost); > package Number_InOut is new Integer_Io(Integer); > use Cost_InOut, Number_InOut; > > Max_Size : Positive; > Int_Range : Natural; > Edge : Edge_Cost; > Input : String (1 .. Max_Size); > Add : String (1 .. 3) := "add"; > Remove : String (1 .. 6) := "remove"; > Link : String (1 .. 4) := "link"; > Cost : String (1 .. 4) := "cost"; > Quit : String (1 .. 4) := "quit"; > Nodea : String (1 .. 6); Nodeb : String (1 .. 6); > > > begin > loop > begin -- Block to contain the exception. -- > New_Line; Put("Please enter command: "); > Get_Line(Input, Max_Size); New_Line; > if Input(1..3) = Add and 10 = Max_Size then > Nodea := Input(5..10); New_Line; > elsif Input(1..6) = Remove and 13 = Max_Size then > Nodea := Input(8..13); New_Line; > elsif Input(1..4) = Link and 19 < Max_Size and Max_Size < 23 then > Nodea := Input(6..11); > Nodeb := Input(13..18); > Int_Range := Max_Size - 19; New_Line; > > case Int_Range is > when 1 => > Edge := Edge_Cost'Value(Input(19..20)); > -- Convert a single numeral -- > when 2 => > Edge := Edge_Cost'Value(Input(20..21)); > -- Convert two numerals -- > when 3 => > Edge := Edge_Cost'Value(Input(20..22)); > -- Convert three numerals -- > when others => null; -- To capture case 0 and 4 -- > end case; > elsif Input(1..4) = Cost and 11 = Max_Size then > Nodea := Input(6..11); > elsif Input(1..4) = Quit then > exit when Input(1..4) = Quit; > else > Put ("Sorry, do not understand command."); New_Line; > Put ("Try again."); New_Line; > end if; > exception > when CONSTRAINT_ERROR => > Put("Error in Cost Value. Enter 1 to 999 only."); > new_line; > end; -- End Block to contain exception -- > end loop; > end Menu;