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.3 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, INVALID_MSGID,XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ec8527ae307e5e17,start X-Google-Attributes: gid103376,public From: "Keith C. McCready" Subject: Newbie: Ada function like C++'s atoi? Date: 2000/03/28 Message-ID: <38e17eab@news.siscom.net>#1/1 X-Deja-AN: 603701649 X-Trace: 28 Mar 2000 22:55:23 -0500, v90-127.forbin.com Organization: Newshosting.com X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: comp.lang.ada X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Date: 2000-03-28T00:00:00+00:00 List-Id: Greetings, I am a college student taking an introductory Ada programming class who is familiar with C/C++. Looking for Ada function similar to atoi. Purpose: I want the following to raise an exception when the user enters a floating point value. Right now, if the user enters a value of 3.1415, the value received by the Get is 3. I would like to read the user input as a character string, convert and validate that the string is an integer value within the range of Percent_Type. ************************* -- subtypes subtype Percent_Type is Integer range 0..100; -- variables: Percent : Percent_Type; -- procedures: procedure Check_Percent ( Percent : out Percent_Type ) is begin -- Check_Percent Validation_Loop: loop Percent_Validation_Block: begin Integer_IO.Get ( Item => Percent ); exit Validation_Loop; exception when CONSTRAINT_ERROR => Text_IO.Put ( Item => "Valid range is 0 to 100" ); Text_IO.New_Line; Text_IO.Skip_Line; when others => Text_IO.Put ( Item => "Enter an integer value of 0 to 100: " ); Text_IO.New_Line; Text_IO.Skip_Line; end Percent_Validation_Block; end loop Validation_Loop; end Check_Percent; ****************** Thanks for any suggestions or comments, Keith C. McCready mccreak9708@uni.edu kmccready@agweb.com