From comp.sys.handhelds Sun Jun 9 13:13:18 1991 Path: seq!ecsgate!mcnc!uvaarpa!haven.umd.edu!ames!think.com!spool.mu.edu!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!brolga!uqcspe!cs.uq.oz.au!grue From: grue@cs.uq.oz.au (Frobozz) Newsgroups: comp.sys.handhelds Subject: Re: Misc. m/l string functs. hp48 Keywords: string, m/l Message-ID: <1774@uqcspe.cs.uq.oz.au> Date: 5 Jun 91 01:41:31 GMT References: <284813da:3337comp.sys.handhelds@hpcvbbs.UUCP> Sender: news@cs.uq.oz.au Reply-To: grue@cs.uq.oz.au Lines: 95 In <284813da:3337comp.sys.handhelds@hpcvbbs.UUCP> akcs.scotty@hpcvbbs.UUCP (SCOTTY THOMPSON) writes: >My first attempts at m/l programming (something simple, yet sweet) were >very successful. Thanks to all who have submitted information to the >board! Don't get put off by what I'm posting, it isn't meant as a direct flame just a word of caution to other users out there. >The following code, in ASC-> format are simple string functions for >Lower-case, Upper-case, UpperFirst (which upper-cases the first character >after any punctuation and lower-cases the rest). >LC$ >-------------------- >%%HP: T(1)A(D)F(.); >"D9D20D29512BF81D0040D9D20CCD20A50008FB976020143130164142818F8542 >3D816414A31149E25131A59E6C03102A6A148161818F9157D8D34150B2130B21 >3038F1" >{Converts string in level 1 to lower-case} >UC$ >--------------------- >%%HP: T(1)A(D)F(.); >"D9D20D29512BF81D0040D9D20CCD20A50008FB976020143130164142818F8542 >3D816414A31169E25131A79E6C03102B6A148161818F9157D8D34150B2130B21 >30DBDF" >{Converts string in level 1 to upper-case} These two routines work quite well but they have some problems. Firstly, they don't handle the full extended character set of the HP48. It is possible to get all kinds of special characters from the keyboard. Enter alpha mode and press: O blue-shift 9 and you should end up with a capital O with a slash across it. Most of these international characters are available in both upper and lower case. It would be nice for these case conversion routines to handle these extra characters properly. Secondly, and maybe more importantly, these routines do not make a copy of the string before case conversion is performed. Try this: "AbCdEf" ENTER ENTER The stack should look like: 2: "AbCdEf" 1: "AbCdEf" Press UC$ and you'll get: 2: "ABCDEF" 1: "ABCDEF" and moreover, you are not able to undo the operation (try it). This could lead to some unexpected results! Now that I've said my bit, I'll include some routines that do work as I've indicated. These two routines handle the entire extended character set (except for the greek letters, there are hardly any cases where both the lowercase and the uppercase character exist), they also duplicate the string before conversion (try the previous test using my routines and it will work as expected) and they also verify that they are passed a string... (i.e. they are just about idiot proof --- famous last words :-) These routines take up approximately 20 extra bytes each, a small price to pay for added safety. This one converts any lowercase characters to upper case. "D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8 AAE4D71643106AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310E A6A148161CF8AF2C8F2D760142164808CB2130B2130BDE1" And this one changes upper case to lower. "D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8 AAE4D71643104AE514A9EC0331B59EAD131FB9EAE131FD9EE51317D962C03102 A6A148161CF8AF2C8F2D760142164808CB2130B2130803A" Pauli seeya Paul Dale | Internet/CSnet: grue@cs.uq.oz.au Dept of Computer Science| Bitnet: grue%cs.uq.oz.au@uunet.uu.net Uni of Qld | JANET: grue%cs.uq.oz.au@uk.ac.ukc Australia, 4072 | EAN: grue@cs.uq.oz | UUCP: uunet!munnari!cs.uq.oz!grue f4e6g4Qh4++ | JUNET: grue@cs.uq.oz.au --