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,b971479ef2fe811a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-21 13:16:07 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stueberl.de!newsr1.ipcore.viaginterkom.de!btnet-peer1!btnet-peer0!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: "Martin Dowie" Newsgroups: comp.lang.ada Subject: Re: Getting valid Integer values !! Date: Tue, 21 Oct 2003 20:15:50 +0000 (UTC) Organization: BT Openworld Message-ID: References: NNTP-Posting-Host: host81-129-50-50.in-addr.btopenworld.com X-Trace: sparta.btinternet.com 1066767350 2371 81.129.50.50 (21 Oct 2003 20:15:50 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Tue, 21 Oct 2003 20:15:50 +0000 (UTC) X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MSMail-Priority: Normal X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:1316 Date: 2003-10-21T20:15:50+00:00 List-Id: "CheGueVerra" wrote in message news:Fxflb.1900$VQ3.239738@news20.bellglobal.com... > [code snippet] > package Entiers is new Text_io.Integer_io (Num => Integer); Assuming you haven't got a prior "use Ada", for new code you should call it "Ada.Text_IO" - "Text_IO" is listed as an "Obsolescent" feature. > IntData : integer range 1000000..9999999; This is an "anonymous type" - generally considered bad (esp. for exported things, not so bad when used localling within a subprogram). You should declare a 'subtype' for this range. > ValidKey : Boolean := false; Not needed - see later > begin > put_line("Test Valid Key"); > > while not ValidKey loop loop > begin > Put_line(" Enter Key :"); > Entiers.Get(IntData); > ValidKey := True; exit; -- this is the canonical method > exception > When Data_error | Constraint_error => > Put_line(" Error reading value, Integer expected of range ..."); > Skip_line; > end; > end loop; > > Put_Line("Valid data entered"); Must be valid to get out of the loop > Keep in mind that I can't use an exit in a loop so I used the boolean value, > it seems to work but ada has surprised me before .... Why can't you use an exit?