From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,MSGID_SHORT autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 29 Oct 92 21:26:10 GMT From: taurus!atlas!erickson@lll-winken.llnl.gov (David Erickson) Subject: Re: DATA_ERROR exception problem Message-ID: <6826@atlas.cs.nps.navy.mil> List-Id: In article dww@inf.fu-berlin.de writes: >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. >Is there any other way to do this besides reading in the >input as a string and patching together an integer myself :-( ? Well, you could read in the input as a string and use the INTEGER_IO GET procedure that reads an integer from a string. Then your exception handling would have to parse the string to discover the reason. >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? A beginner's perspective: beginners can break *anything*. -Dave Erickson