home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.rexx
- Path: sparky!uunet!csfb1!jbrock
- From: jbrock@csfb1.fir.fbc.com (John Brock)
- Subject: Re: Lower-case alphabetic set
- Message-ID: <C0Hr59.70x@csfb1.fir.fbc.com>
- Sender: news@csfb1.fir.fbc.com (Usenet News Account)
- Reply-To: uunet!csfb1!jbrock
- Organization: First Boston Corporation
- References: <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU> <C0CDCz.Co3@csfb1.fir.fbc.com> <C0E55F.IK5@csfb1.fir.fbc.com> <16B4E7C5F.MCMASTER@LSTC2VM.stortek.com>
- Date: Thu, 7 Jan 1993 16:00:44 GMT
- Lines: 94
-
- In article <16B4E7C5F.MCMASTER@LSTC2VM.stortek.com>, MCMASTER@LSTC2VM.stortek.com (Jim McMaster) writes:
- |> In article <C0E55F.IK5@csfb1.fir.fbc.com>
- |> jbrock@csfb1.fir.fbc.com (John Brock) writes:
- |>
- |> >In article <C0CDCz.Co3@csfb1.fir.fbc.com>, jbrock@csfb1.fir.fbc.com (John Brock) writes:
- |> >|> In article <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU>, Wan Hasan Abdullah <WAN@UTMJB.BITNET> writes:
- |> >|> |> Hello netters!
- |> >|> |>
- |> >|> |> I found that, there's a function to translate all words to upper case
- |> >|> |> but I could'nt find in HELP REXX to form the words from upper case to
- |> >|> |> lower case by using a function. Could anyone help me to solve this
- |> >|> |> problem?
- |> >|> |>
- |> >|> |> Thanks in advance.
- |> >|> |>
- |> >|> |> -WAN-
- |> >|>
- |> >|> How about:
- |> >|>
- |> >|> lowercase: procedure
- |> >|> return translate(arg(1), xrange(), translate(xrange()))
- |> >|>
- |> >|> I like this because it is consise and generic. It should work as it
- |> >|> stands for any language, and it lets me avoid typing out all the upper
- |> >|> and lower case letters by hand (which I think looks ugly, even though
- |> >|> it's clearly more efficient to do it that way).
- |> >
- |> >I'm responding to my own post, as there have been other posts
- |> >expressing concern about this type of procedure translating
- |> >non-alphabetic characters.
- |> >
- |> >On my system at least, all non-alphabetic characters are unchanged by
- |> >the translate function when used with only one argument. If this isn't
- |> >part of the language definition it ought to be! In any case you could
- |> >argue that if c ^== translate(c) for any character c, then c by
- |> >definition has a distinct upper case form, and my lowercase function
- |> >makes sense.
- |> >
- |> >It even makes a certain kind of sense if translate is generalized
- |> >(e.g., mapping a ==> b, b ==> c, and c ==> a), an long as it never maps
- |> >two distinct characters to the same character.
- |> >
- |> >Here is a procedure which checks which characters on a given system
- |> >are affected by the translate function:
- |> >
- |> > x = xrange()
- |> > y = ""
- |> >
- |> > do i = 1 to length(x)
- |> > c = substr(x, i, 1)
- |> > if c ^== translate(c) then y = y || c
- |> > end
- |> >
- |> > say length(y) y
- |> >
- |> >On my (VM/CMS) system this yields:
- |> >
- |> > 26 abcdefghijklmnopqrstuvwxyz
- |> >
- |> >--
- |> >John Brock
- |> >uunet!csfb1!jbrock
- |> >jbrock@csfb1.fir.fbc.com
- |>
- |> John...this does not work in the general case. Your "translate(c)"
- |> uses the default translate tables, which are designed to translate only
- |> lower case alphabetic to upper case alphabetic.
- |>
- |> The input table "xrange('A','Z')" and output table "xrange('a','z')"
- |> are not at all the same. You certainly will translate "A" (x'C1') to
- |> "a" (x'81'), but you also translate the backslash (x'E0') to the EBCDIC
- |> superscript character (X'A0'). EBCDIC has a lot of characters
- |> (printable and nonprintable) between the letters I and J, as well as
- |> between R and S, which will also get translated.
- |>
- |> Your technique would work in an ASCII system, bacause all upper-case
- |> alphabetics are in the range X'41'-X'5A' (with no intermixed
- |> characters), and lower-case alphabetics are X'61'-X'7A'.
- |>
- |> Jim McMaster
-
- I'm sorry, but I don't understand your objection. What I demonstrated
- above is that (at least on my VM/CMS (EBCDIC!) system) the only
- characters affected by the translate function are the lower case
- alphabetic characters. So it doesn't matter that my lowercase
- procedure translates non-alpha characters, because it translates them
- to themselves, leaving them unchanged. My function does not, as you
- stated, change x'E0' to x'A0', at least not on my system. Try it! Am
- I missing something?
-
- --
- John Brock
- uunet!csfb1!jbrock
- jbrock@csfb1.fir.fbc.com
-