From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Why does this input get "skipped"?
Date: Sat, 20 Aug 2016 17:50:43 -0700
Date: 2016-08-20T17:50:43-07:00 [thread overview]
Message-ID: <npatt9$m9l$1@dont-email.me> (raw)
In-Reply-To: <c10f7c57-5657-4ef4-87e5-285c96610b62@googlegroups.com>
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
next prev parent reply other threads:[~2016-08-21 0:50 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 [this message]
2016-08-21 1:04 ` John Smith
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