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.1 required=5.0 tests=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no 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-03 12:36:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Newbie question on Ada TExt_IO Date: Thu, 3 Oct 2002 14:35:36 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <93d4dcd4.0210031020.b0cca2b@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1033673762 62179 137.194.161.2 (3 Oct 2002 19:36:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 3 Oct 2002 19:36:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:29500 Date: 2002-10-03T14:35:36-05:00 ----- Original Message ----- From: "Justin" Newsgroups: comp.lang.ada To: Sent: Thursday, October 03, 2002 1:20 PM Subject: Newbie question on Ada TExt_IO > Hi, > > I'm relatively new to Ada. I've read 1/2 of Programming in Ada95 by > Barnes, done half of Lovelace and read as much as I can stomach of the > Ada RM. Forgive me if this question is too basic, but I've been unable > to see any reference to it in the previous documentation. > > I'm doing TextIO from the command prompt. But I'm having difficulty > validating the input. For example I'm asking the user to enter a > number, let's say I'm expecting an integer between 1 and 6 > > X:Integer; > ... > Put("Please enter a number between 1 and 6); > Get(x); > > But what if they give me 'abc' or 4.44 or simply > 1230000000000000000000000000000000000000000000000000000000000000000000000 > First, I would be sure that the user prompt is precise in defining the desired input. 4.44 _is_ "number between 1 and 6". If what you meant is "Please enter an integer from 1 to 6 inclusive", I would say just that. > How can I handle this? From my take on what I've read I should avoid > exception handling for things I'm not expecting, so I've ruled out > exceptions, that leaves me with obtaining a value of generic type and > evalutating the type at run-time...how can I do this? Is this the > right strategy? I have seen some discussion deprecating the use of exception handlers for validating user input, but frankly, I've never been convinced, and I use them. > > Thanks for they help, > Justin > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >