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 10:58:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed1.bredband.com!bredband!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Newbie question on Ada TExt_IO Date: Fri, 4 Oct 2002 17:58:50 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: <93d4dcd4.0210031020.b0cca2b@posting.google.com> NNTP-Posting-Host: kiuk0156.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1033754330 25039 129.241.83.82 (4 Oct 2002 17:58:50 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Fri, 4 Oct 2002 17:58:50 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:29517 Date: 2002-10-04T17:58:50+00:00 List-Id: On Fri, 04 Oct 2002 17:34:42 GMT, Justin Birtwell wrote: > > 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; OK but note that your program will not ask you again if you press something other than a integer value. > > 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 Well you will learn that this is a great benifit. In the beginning it can be a bit annoying, but you will soon be diseplined enough to avoid all these problems and you will fully see why strong typing is the only way to go. Preben -- Ada95 is good for you. http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf