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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bac902cf9fd6564b X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Case Sensitivity Date: 2000/05/12 Message-ID: <8fgm37$dbh$1@hobbes2.crc.com>#1/1 X-Deja-AN: 622504348 References: <958056490.47876@hearts.q-net.net.au> <391BC9D0.F20E8D22@bton.ac.uk> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@crc.com X-Trace: hobbes2.crc.com 958127015 13681 198.175.145.56 (12 May 2000 10:23:35 GMT) Organization: CRC: A wholly owned subsidiary of Thermo Electron NNTP-Posting-Date: 12 May 2000 10:23:35 GMT Newsgroups: comp.lang.ada Date: 2000-05-12T10:23:35+00:00 List-Id: John -- Won't one get Data_Error instead of Constraint_Error when using an instantiation of Enumeration_IO? John English wrote in message news:391BC9D0.F20E8D22@bton.ac.uk... > Cameron McShane wrote: > > We need a menu that needs to be case-'in'sensitive. I am using an enumerated > > data type for the 3 menu options ie: > > > > type Menu_Options is (buy, read, done) > > > > If the user is to be allowed to enter Buy or BUY or bUy - etc, do I need to > > make the data type > > > > type Menu_Options is (buy, Buy, bUY, etc > > > > or is there a way of converting user input to all lower case? > > If you instantiate Ada.Text_IO.Enumeration_IO for your Menu_Options > type, the user will be able to enter any of the three names in any > case mixture and you will get back the corresponding Menu_Options > result. You will also be able to display the three values using > Put -- the default is all uppercase but you can also select output > in all lowercase. Enumeration_IO for input lets you forget about > case differences completely. > > In other words, rather than reading a string, read a Menu_Options > value directly. If the user types anything other than one of your > three possible values, you'll get a Constraint_Error, so checking > for invalid input is simpler too. > > ----------------------------------------------------------------- > John English | mailto:je@brighton.ac.uk > Senior Lecturer | http://www.it.bton.ac.uk/staff/je > Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** > University of Brighton | -- see http://burks.bton.ac.uk > -----------------------------------------------------------------