From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Weird string I/O problem
Date: Thu, 27 Nov 2008 11:27:17 +0100
Date: 2008-11-27T11:27:17+01:00 [thread overview]
Message-ID: <9mslgg.ngv.ln@hunter.axlog.fr> (raw)
In-Reply-To: <f1e7e583-4e47-4e8f-a186-14ff4a00fc30@a3g2000prm.googlegroups.com>
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
next prev parent reply other threads:[~2008-11-27 10:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-26 5:52 Weird string I/O problem Jerry
2008-11-26 7:24 ` christoph.grein
2008-11-26 7:38 ` christoph.grein
2008-11-26 8:25 ` Dmitry A. Kazakov
2008-11-26 9:07 ` Jean-Pierre Rosen
2008-11-26 15:21 ` John McCormick
2008-11-26 15:56 ` Adam Beneschan
2008-11-27 10:13 ` Jean-Pierre Rosen
2008-12-01 16:17 ` Adam Beneschan
2008-11-27 4:46 ` Jerry
2008-11-27 10:27 ` Jean-Pierre Rosen [this message]
2008-12-01 19:47 ` anon
2008-12-02 5:44 ` christoph.grein
2008-12-02 6:55 ` anon
2008-12-02 7:53 ` christoph.grein
2008-12-02 16:39 ` Adam Beneschan
2008-12-03 9:16 ` anon
2008-12-03 10:42 ` christoph.grein
2008-12-03 12:21 ` John B. Matthews
2008-12-04 0:15 ` anon
2008-12-04 7:31 ` christoph.grein
2008-12-04 7:56 ` Ludovic Brenta
2008-12-04 8:46 ` Georg Bauhaus
2008-12-03 11:35 ` stefan-lucks
2008-12-04 0:27 ` anon
2008-12-04 8:58 ` stefan-lucks
2008-12-04 22:54 ` anon
2008-12-05 9:06 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox