[comp.sys.handhelds] Misc. m/l string functs. hp48

akcs.scotty@hpcvbbs.UUCP (SCOTTY THOMPSON) (06/02/91)

My first attempts at m/l programming (something simple, yet sweet) were
very successful.  Thanks to all who have submitted information to the
board!

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).

Also included here are two additional routines.  One converts a string of
less than 256 characters to a global name, and the other converts a
global name to a string.

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}

UFIRST$
----------------------
%%HP: T(1)A(D)F(.);
"D9D20D29512BF81D0040D9D20CCD20890008FB976020143130164142818F8540
7D816485014A31149E2D431B59E2A231A79E6B331169E223860038403102B6A1
4860208609084064103102A6A1486600850161818F915C98D34150B2130B2130
4ED0"

{Converts string in level 1 to mixed-upper/lower case, depending whether
or not the alpha character follows a non-alpha character (A-Z or a-z).
For example, "P. O. BOX 123A-C, REDONDO BEACH, CA..." Would end-up as:
"P. O. Box 123A-C, Redondo Beach, Ca..."

STR->GN
------------------------
%%HP: T(1)A(D)F(.);
"D9D20D29512BF81D0040D9D20C2A2050000756602C230636508813082E4676D3
6D9D20852302AC81B2130D9D20F6E30AA526C1C16CCD20F60008FB9760201438
18F09130141174143131174143818F84174819F03484E20144164148161AE8A6
D44114B148171161A6D50F8D34150B9F06B2130B2130B2130778F"

{Converts string in level 1 to global name}.  This is useful for many
things, I've since found-out.  For example, putting " " on the stack and
executing STR-GN will leave a global variable on the stack as ' '.  This
cannot be entered from the keyboard, so anything stored in this variable
won't get purged, etc.  Try it!  I've come-up with some very interesting
tidbits this way.  Another example: Create a directory called ' '.  It
will show-up as a blank var key with the directory bar above it.  Press
this key to go to this directory.  Now type "" STR->GN CRDIR.  You now
have a 'hidden' subdirectory.  To go to this "upper" subdirectory, type
"" STR-GN EVAL.  Did you notice the path at the top of the display? 
Turns-out that going to this null directory dosen't show the extra space
in the path listing (the parent directory to this one).  Currently, I'm
nested 3 levels deep, plus the "space" directory.  Try to purge this
directory from the keyboard!  It appears exactly like a "HOME" directory,
so I've been putting my programs and such here that are miscellaneous and
keeping the important "stuff" in my real HOME directory.  Anyone I let
use my calculator now will be logged-on to a virtually indestructible
directory.

GN->STR
----------------------
%%HP: T(1)A(D)F(.);
"D9D20D29512BF81B2040D9D209EB50B2130B21304E11"

{Converts global name in level 1 to a string object}.  The code is much
shorter because there is an internal routine that does this conversion. 
This is just the opposite of STR->GN.

Happy computing.  Oh, p.s., I'm not responsible.  These routines work
fine on my REV-E machine, but ya'll know the caveates.

grue@cs.uq.oz.au (Frobozz) (06/05/91)

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
--