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-Thread: 103376,4819e43c270862a9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Newbie Question: Integer_IO an Data_error Date: Fri, 27 Mar 2009 09:59:22 +0100 Organization: Adalog Message-ID: References: <873ad0ueva.fsf@babel.localdomain> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1238135995 16104 195.25.228.57 (27 Mar 2009 06:39:55 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Fri, 27 Mar 2009 06:39:55 +0000 (UTC) User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:5333 Date: 2009-03-27T09:59:22+01:00 List-Id: Tim Rowe a �crit : > Zachary Kline wrote: >> The problem comes with Data_errors: if I try to >> handle that case the same way, we get a seemingly infinite loop. > > > I'm an Ada newbie too, but the first thing I wonder is what Get does > with the input characters if they don't match the expected type. I > wonder whether it leaves them on the input stream -- in which case > subsequent attempts to read the input will try to read the same > characters each time. Until somebody who knows what they're talking > about comes along (won't be long) I'd try doing a string Get after a > failed numeric get, to see what's still in the input stream. When a character is incorrect, the current position stays on it, to allow you to do a Get(Char) and see what happened. OTOH, it means that you must do a skip_line to get rid of the remaining of the line, and get a fresh one. A typical reading loop is: loop begin Get (N); exit; -- OK, no exception exception when Data_Error => Skip_Line; Put_Line ("Error, try again"); end; end loop; -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr