comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Newbie question on Ada TExt_IO
Date: Thu, 03 Oct 2002 19:35:56 GMT
Date: 2002-10-03T19:35:56+00:00	[thread overview]
Message-ID: <w_0n9.124$R71.21986617@newssvr13.news.prodigy.com> (raw)
In-Reply-To: 93d4dcd4.0210031020.b0cca2b@posting.google.com

> Put("Please enter a number between 1 and 6);
> Get(x);
>
> But what if they give me 'abc' or 4.44 or simply
> 1230000000000000000000000000000000000000000000000000000000000000000000000
  To be really snazzy, use Get_Line and read into a String, then check the
string to make sure it consists of the desired kind of input - in this
case a single digit in '1' .. '6' and perhaps spaces.  If it's OK,
then Get from the string, if not tell the user just what he did wrong.
  Substantially simpler is to catch the exception and go back and
repeat the Put prompt and the Get.  Use exceptions judiciously, not
just for really totally surprising situations.



  parent reply	other threads:[~2002-10-03 19:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-03 18:20 Newbie question on Ada TExt_IO Justin
2002-10-03 18:50 ` Matthew Heaney
2002-10-03 19:05 ` Jeffrey Carter
2002-10-03 19:35 ` David C. Hoos
2002-10-03 19:35 ` tmoran [this message]
2002-10-03 19:43 ` Preben Randhol
2002-10-03 19:55   ` Matthew Heaney
2002-10-03 20:07     ` Preben Randhol
2002-10-04  2:42 ` SteveD
2002-10-04 17:49   ` Justin Birtwell
2002-10-04 18:00     ` David C. Hoos
2002-10-04 18:04       ` Preben Randhol
2002-10-04 18:00     ` Preben Randhol
2002-10-04 18:02       ` Preben Randhol
2002-10-04 18:34     ` tmoran
2002-10-04 17:34 ` Justin Birtwell
2002-10-04 17:58   ` Preben Randhol
2002-10-04 18:13   ` tmoran
2002-10-04 20:07   ` Jeffrey Carter
2002-10-07  8:26     ` Fraser Wilson
2002-10-07 19:44       ` Jeffrey Carter
2002-10-05  2:43   ` SteveD
2002-10-05  5:25     ` tmoran
  -- strict thread matches above, loose matches on Subject: below --
2002-10-07  6:01 Grein, Christoph
2002-10-07  8:27 Grein, Christoph
2002-10-07 11:48 ` Fraser Wilson
2002-10-07 12:46   ` Robert A Duff
replies disabled

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