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, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e2413c4fccb33dbc X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!npeer.de.kpn-eurorings.net!npeer-ng2.kpn.DE!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: determining input data type Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <214384a8-9f78-4797-a194-457166456462@i18g2000prf.googlegroups.com> Date: Sat, 18 Oct 2008 10:00:21 +0200 Message-ID: NNTP-Posting-Date: 18 Oct 2008 10:00:21 CEST NNTP-Posting-Host: d63eb7f5.newsspool2.arcor-online.net X-Trace: DXC=jZOIAN6XX_H^B]`=U:WelBA9EHlD;3YcB4Fo<]lROoRA4nDHegD_]RE>gjG On Fri, 17 Oct 2008 23:53:54 -0700 (PDT), deadlyhead wrote: > Using Ada.Integer_Text_IO.Get does some work for you, though. For > instance, if the user inputs 214yy0, it puts 214 in My_Int and > continues on its way. This may not be what you want, thus some actual > text processing may be in order. Yes, this was one of the motivations behind: http://www.dmitry-kazakov.de/ada/strings_edit.htm Your example reworked for Strings_Edit: with Ada.Text_IO; use Ada.Text_IO; with Strings_Edit.Integers; use Strings_Edit.Integers; procedure Int_Test is My_Int : Integer; begin Put ("Give me some input, and I will tell you if it is an integer:"); My_Int := Value (Get_Line); Put_Line (Image (My_Int) & " is an integer!"); exception when Constraint_Error => Put_Line ("That was a too large integer!"); when End_Error => Put_Line ("You entered nothing!"); when Data_Error => Put_Line ("That was not an integer!"); end Int_Test; The function Value takes care to check the whole string for containing integer and nothing but integer. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de