From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4228cd5af810e7ab X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Get (integer) help Date: 1997/05/22 Message-ID: <3384A328.5DD2@gsfc.nasa.gov>#1/1 X-Deja-AN: 243149676 References: <864270399.21858@dejanews.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-05-22T00:00:00+00:00 List-Id: sbredemeyer@westpac.com.au wrote: > > I am relatively new to Ada 95 and am having trouble with a GetInt library unit that I have created. It is a simple procedure with in parms of Min_Allow, Max_Allow and Prompt_Text that out's The_Integer. > I have created user defined exceptions handlers for integer values > outside the range of Min_Allow .. Max_Allow (The_Integer is > unconstrained, no subtype declaration), and used Data_Error and > Constraint_Error as well. The problem I am having is that my exception handler handles inputs such as Strings, Integer'Last and integers out of range Min_Allow .. Max_Allow but spits the dummy if I input a real. > I know what is happening (i.e. given 1.234, GetInt gets 1 as valid > integer input with the marker pointing to "." which is then read in with the next execution of the procedure) but not how to > get around it. I have been trying to find documentation on look_ahead > which I think might solve my problem, but with no success. > Can anybody help? I'm not clear what behavior you want. If your program calls GetInt, and the user types "1.234", do you want GetInt to say "1.234 is not an integer" ? If so, you need to read a whole line, using Get_Line, and not just an integer, using Text_IO.Integer_IO.Get. I wrote a similar package (in Ada 83). You can download it from my web page: http://www710.gsfc.nasa.gov/~sal714/homepage.html follow the link to "Ada packages for Friendly Text_Io and Robot_Math", and download text_io.tar.gz > > Please let me know if I have submitted this to an > inappropriate > NewsGroup. This is my first visit to DejaNews. You've come to the right place! > > Thankyou > > -------------------==== Posted via Deja News ====----------------------- > http://www.dejanews.com/ Search, Read, Post to Usenet -- - Stephe