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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8dd8ee71ca4e5206 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-04 19:43:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!204.71.34.15!news-out.cwix.com!newsfeed.cwix.com!feed2.news.rcn.net!rcn!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: "SteveD" Newsgroups: comp.lang.ada References: <93d4dcd4.0210031020.b0cca2b@posting.google.com> Subject: Re: Newbie question on Ada TExt_IO X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.225.227.101 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1033785828 12.225.227.101 (Sat, 05 Oct 2002 02:43:48 GMT) NNTP-Posting-Date: Sat, 05 Oct 2002 02:43:48 GMT Organization: AT&T Broadband Date: Sat, 05 Oct 2002 02:43:48 GMT Xref: archiver1.google.com comp.lang.ada:29529 Date: 2002-10-05T02:43:48+00:00 List-Id: "Justin Birtwell" wrote in message news:Sikn9.1513$Mw4.1034@nwrddc01.gnilink.net... > Is_Digit a hack of a procedure that compares the 1 character string to all > 10 digits characters. I really have a lot to learn. What's giving me the > hardest time is working within the confines of strict/strong typing. The > Ada.Characters.Handling package already has an Is_Digit function, but it's > expecting a character not a single item String array! How can I convert > from one into the other? I have the distinct feelling like I'm reinventing > the wheel. Aren't packages aready made to do alot of this > converting/validation? If so where are they? How can one access them? > Does the RM list all the packages provided by Ada or are there more to be > discovered? > First, if you happen to be using GNAT on windows, go to the help file "Ada 95 Reference Manual". Select "Annexes", then "Annex A: Predefined Language Environment", then "A. Predefined Language Environment". Or you can go to http://www.adaic.org/standards/95lrm/html/RM-A.html which has the same information. This page shows the standard libraries include in Ada 95. I recommend perusing these to see what is available. Second... about your program. It runs if you change the Input_Data( 1..1) to Input_Data(1) and add a couple of "with" and "use" clauses to make the built in library function available... but... If you enter "42" the program is happy and recognizes the value entered as "4". Hmmm... I suspect not what the user would expect. Try this one (and please reassure me that this is not a homework assignment I just completed for you) with Ada.Text_Io; use Ada.Text_Io; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; procedure Test_IO_3 is Input: String(1..256); Last:Integer; result : Integer; begin ReadLoop: loop Put("Please enter a number between 1 and 6 > "); Get_Line(Item=>Input,Last=>Last); declare Input_Data : String := Trim( Input( 1 .. Last ), Both ); begin if Input_Data'Length = 1 and then Input_Data(1) in '1' .. '6' then result := Integer'Value( Input_Data( 1 .. 1 ) ); Exit ReadLoop; end if; Put_Line("Invalid entry, try again."); end; end loop ReadLoop; Put_Line("Thank you"); exception when others=> Put_Line("Error, Invalid data."); end Test_IO_3; > thanks to one and all, > Justin > > > >