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: John English Subject: Re: Case Sensitivity Date: 2000/05/12 Message-ID: <391BC9D0.F20E8D22@bton.ac.uk>#1/1 X-Deja-AN: 622479303 Content-Transfer-Encoding: 7bit References: <958056490.47876@hearts.q-net.net.au> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@bton.ac.uk X-Trace: saturn.bton.ac.uk 958122530 11772 193.62.183.204 (12 May 2000 09:08:50 GMT) Organization: University of Brighton Mime-Version: 1.0 NNTP-Posting-Date: 12 May 2000 09:08:50 GMT Newsgroups: comp.lang.ada Date: 2000-05-12T09:08:50+00:00 List-Id: 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 -----------------------------------------------------------------