comp.lang.ada
 help / color / mirror / Atom feed
From: bloom-picayune.mit.edu!snorkelwacker.mit.edu!ira.uka.de!ira.uka.de!math.f u-berlin.de!weberwu@bloom-beacon.mit.edu  (Debora Weber-Wulff)
Subject: DATA_ERROR exception problem
Date: 29 Oct 92 10:44:25 GMT	[thread overview]
Message-ID: <X7D8JTH@math.fu-berlin.de> (raw)

[Now that we have the umlauts sorted out, the next problem!]

I want to write a compeletly safe input procedure for integers:
I GET an integer, and if DATA_ERROR is raised, I want to loop
around until I get a decent answer. 

My problem is that DATA_ERROR is raised on two different conditions:
an integer being illegal, i.e. out of bounds, or an illegal
character being encountered (such as when I enter "1.0" or "z").
The problem ist that in the former case, the input buffer has been
emptied (all digits read); in the latter, the illegal character
(and all following characters) remain in the input buffer.
How can I differentiate the two cases, so that I can 
GET_LINE (input_garbage, input_garbage_size) and reprompt for input?

On Meridian's PC Ada I get an endless loop if I don't remove the
garbage, and have to enter extra garbage if the problem was a bound
error (!!). Is there any other way to do this besides reading in the
input as a string and patching together an integer myself :-( ?

Stupid me wanted to introduce my beginners to exceptions from the
start - we specified type-safe input, and I expected it to be
relatively straight-forward to implement in Ada. What am I missing?

Thanks for any comments, by mail or by news.
   
-- 
Debora Weber-Wulff                       dww@inf.fu-berlin.de
Institut fuer Informatik                 +49 30 89691 124
Nestorstr. 8-9                           (INCLUDE "standard.disclaimer")
D-W-1000 Berlin 31                       (PRINTN (WITTY-MESSAGE TODAY))

             reply	other threads:[~1992-10-29 10:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-29 10:44 bloom-picayune.mit.edu!snorkelwacker.mit.edu!ira.uka.de!ira.uka.de!math.f [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-29 21:26 DATA_ERROR exception problem David Erickson
1992-10-31  6:34 munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!cs.adelaide.edu.au!
1992-11-01 16:55 Michael Feldman
1992-11-06  3:54 Michael Feldman
replies disabled

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