comp.lang.ada
 help / color / mirror / Atom feed
From: John Smith <yoursurrogategod@gmail.com>
Subject: Re: Why does this input get "skipped"?
Date: Sat, 20 Aug 2016 18:04:21 -0700 (PDT)
Date: 2016-08-20T18:04:21-07:00	[thread overview]
Message-ID: <a86bf07a-d23f-4f13-9dde-cc512c419bde@googlegroups.com> (raw)
In-Reply-To: <npatt9$m9l$1@dont-email.me>

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.

  reply	other threads:[~2016-08-21  1:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-20 22:41 Why does this input get "skipped"? John Smith
2016-08-20 23:16 ` Jeffrey R. Carter
2016-08-21  0:01   ` John Smith
2016-08-21  0:36     ` John Smith
2016-08-22  5:00       ` J-P. Rosen
2016-08-22 22:18       ` rieachus
2016-08-23  6:22         ` J-P. Rosen
2016-08-24 10:34           ` rieachus
2016-08-21  0:50     ` Jeffrey R. Carter
2016-08-21  1:04       ` John Smith [this message]
2016-08-21  4:07         ` Jeffrey R. Carter
2016-08-21  0:00 ` rieachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox