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-03 12:36:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr13.news.prodigy.com.POSTED!3bae8248!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Newbie question on Ada TExt_IO References: <93d4dcd4.0210031020.b0cca2b@posting.google.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.112.203.209 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr13.news.prodigy.com 1033673756 ST000 67.112.203.209 (Thu, 03 Oct 2002 15:35:56 EDT) NNTP-Posting-Date: Thu, 03 Oct 2002 15:35:56 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: [[PGGTSDZRRQBQH]]RKB_UDAZZ\DPCPDLXUNNHLIWIWTEPIB_NVUAH_[BL[\IRKIANGGJBFNJF_DOLSCENSY^U@FRFUEXR@KFXYDBPWBCDQJA@X_DCBHXR[C@\EOKCJLED_SZ@RMWYXYWE_P@\\GOIW^@SYFFSWHFIXMADO@^[ADPRPETLBJ]RDGENSKQQZN Date: Thu, 03 Oct 2002 19:35:56 GMT Xref: archiver1.google.com comp.lang.ada:29501 Date: 2002-10-03T19:35:56+00:00 List-Id: > Put("Please enter a number between 1 and 6); > Get(x); > > But what if they give me 'abc' or 4.44 or simply > 1230000000000000000000000000000000000000000000000000000000000000000000000 To be really snazzy, use Get_Line and read into a String, then check the string to make sure it consists of the desired kind of input - in this case a single digit in '1' .. '6' and perhaps spaces. If it's OK, then Get from the string, if not tell the user just what he did wrong. Substantially simpler is to catch the exception and go back and repeat the Put prompt and the Get. Use exceptions judiciously, not just for really totally surprising situations.