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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.176.64.225 with SMTP id i88mr11038580uad.5.1471741461512; Sat, 20 Aug 2016 18:04:21 -0700 (PDT) X-Received: by 10.157.2.39 with SMTP id 36mr964836otb.3.1471741461471; Sat, 20 Aug 2016 18:04:21 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!j37no9673334qta.0!news-out.google.com!d68ni33966ith.0!nntp.google.com!f6no11606413ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 20 Aug 2016 18:04:21 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18f:900:8350:55e9:c515:61e6:b20f; posting-account=AvekzAoAAABj-TclKcOWQmXwA49MFPGX NNTP-Posting-Host: 2601:18f:900:8350:55e9:c515:61e6:b20f References: <07632b3f-f419-4865-a8f8-01b568a6883e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why does this input get "skipped"? From: John Smith Injection-Date: Sun, 21 Aug 2016 01:04:21 +0000 Content-Type: text/plain; charset=UTF-8 X-Received-Bytes: 2695 X-Received-Body-CRC: 3687691162 Xref: news.eternal-september.org comp.lang.ada:31478 Date: 2016-08-20T18:04:21-07:00 List-Id: On Saturday, August 20, 2016 at 8:50:52 PM UTC-4, Jeffrey R. Carter wrote: > On 08/20/2016 05:01 PM, John Smith wrote: > > > > Hi, I do have an Ada.Integer_Text_IO.Get above this call (some ways above it.) > > > > How can I clear out that line terminator? Another call to Get_Line, but not save the input? > > The way to skip the next line terminator in an input file is with a call to > Skip_Line. > > However, when using Text_IO for input from standard input, it's best to always > input an entire line at a time into a String, and then deal with the line in the > String. The fact that Get leaves a line terminator in the buffer wreaks havoc on > error handling. > > Get_Speed : loop > Ada.Text_IO.Put (Item => "Enter desired speed: "); > > Speed_Line : declare > Line : constant String := Ada.Text_IO.Get_Line; > > Last : Natural; > begin -- Speed_Line > Speed_IO.Get (From => Line, Item => Speed, Last => Last); > > exit Get_Speed; > exception -- Speed_Line > when others => > Ada.Text_IO.Put_Line (Item => "Enter a valid speed."); > end Speed_Line; > end loop Get_Speed; > > -- > Jeff Carter > "People called Romanes, they go the house?" > Monty Python's Life of Brian > 79 Just to be sure, Speed_IO.Get, you meant Ada.Integer_Text_IO.Get, yes? I've made mistakes like this, but I want to be sure that I'm on the right page as well.