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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Why does this input get "skipped"? Date: Sat, 20 Aug 2016 17:50:43 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <07632b3f-f419-4865-a8f8-01b568a6883e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Sun, 21 Aug 2016 00:50:51 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d7c030f56102b58a2c16dea977db88bb"; logging-data="22837"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3kLDQYCeaICuGnHHbCpGxx8d1yaCql1M=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: Cancel-Lock: sha1:2UdzmKB/eObt1k+TOLM7hHH7BfI= Xref: news.eternal-september.org comp.lang.ada:31477 Date: 2016-08-20T17:50:43-07:00 List-Id: 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