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,d54559bde05f5bb8 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.buerger.net!news.ecp.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Weird string I/O problem Date: Thu, 27 Nov 2008 11:27:17 +0100 Organization: Adalog Message-ID: <9mslgg.ngv.ln@hunter.axlog.fr> References: NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1227777300 15507 195.25.228.57 (27 Nov 2008 09:15:00 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Thu, 27 Nov 2008 09:15:00 +0000 (UTC) User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:2823 Date: 2008-11-27T11:27:17+01:00 List-Id: Jerry a �crit : > So my problem is solved, but I'm still puzzled. All I'm trying to is > to very simple IO from keyboard and monitor to enter e.g. a numeric > parameter into my program as well as, say, a file name. So any Get on > a Float followed by any of the Get_Line routines will raise this > problem. It just seems odd to me that for such a simple application, I > have to remember to clear the dangling line terminator after the Get > on a Float. (Or, in the present case, since I have easy access to the > code, to have the Get_Line do it for me.) > The real issue is that you never know what the user will type! Suppose you want to get a real value, and the user types: 3.14 Ooops one of my keys got stuck ------------------------------- What should you do? Clearly, the language has no opinion about this, it is just designed in a way that allows /you/ to implement anything you want. For example: 1) Ignore everything until EoL => call skip_line 2) Make it an error => write a message if End_Of_Line is false after reading. 3) Allow only spaces after the number => Read the remaining of the line with Get_Line, and do your own analysis 4) Consider that it is text for the next get of string, unless there is no remaining text on the same line => if end_of_line then skip_line etc... -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr