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,FREEMAIL_FROM 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 10:34:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!cyclone1.gnilink.net!spamfinder.gnilink.net!nwrddc01.gnilink.net.POSTED!53ab2750!not-for-mail From: "Justin Birtwell" 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.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Fri, 04 Oct 2002 17:34:42 GMT NNTP-Posting-Host: 151.202.46.147 X-Complaints-To: abuse@verizon.net X-Trace: nwrddc01.gnilink.net 1033752882 151.202.46.147 (Fri, 04 Oct 2002 13:34:42 EDT) NNTP-Posting-Date: Fri, 04 Oct 2002 13:34:42 EDT Xref: archiver1.google.com comp.lang.ada:29514 Date: 2002-10-04T17:34:42+00:00 List-Id: Hello All, To everyone that replied to my question..thank you. Through your responses I learned allot. I learned how I could raise an error with in a loop by nesting a block, I also learned about Skip_Line and Get_Line, the Ada.Strings.Trim and the Ada.Strings.Fixed.Index packages. After reading everyone's post I"ve decided that the best course of action is to validate the input as much as I possibly can but still supply some exception handling for anything that I haven't anticipated. So my validation looks like this Accept entire line using Get_Line into string(1..256); Check if first character is a digit Check if digit is between 1 and 6 error handling Here's the code: with Text_Io;use Text_Io; with StringFunctions;use StringFunctions; procedure Test_IO_2 is Input: String(1..256); N:Integer; Success:Boolean:=false; Last:Integer; begin while success /=true loop Put("PLease enter a number between 1 and 6"); Get_Line(Item=>Input,Last=>Last); if Is_Digit(Input(1..1)) then N:=Integer'Value(Input(1..1)); if N>=1 and N<=6 then Success:=True; end if; else success:=false; Put_Line("Invalid entry, try again."); end if; end loop; Put_Line("Thank you"); exception when others=> Put_Line("Error, Invalid data."); end; 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? thanks to one and all, Justin