home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / rexx / 1460 < prev    next >
Encoding:
Text File  |  1993-01-06  |  3.4 KB  |  92 lines

  1. Newsgroups: comp.lang.rexx
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!agate!dog.ee.lbl.gov!hellgate.utah.edu!csn!stortek!LSTC2VM.stortek.com!MCMASTER
  3. From: MCMASTER@LSTC2VM.stortek.com (Jim McMaster)
  4. Subject: Re:      Lower-case alphabetic set
  5. Message-ID: <16B4E7C5F.MCMASTER@LSTC2VM.stortek.com>
  6. Sender: usenet@stortek.com
  7. Nntp-Posting-Host: lstc2vm.stortek.com
  8. Organization: StorageTek SW Engineering
  9. References: <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU> <C0CDCz.Co3@csfb1.fir.fbc.com> <C0E55F.IK5@csfb1.fir.fbc.com>
  10. Date: Wed, 6 Jan 1993 15:50:37 GMT
  11. Lines: 79
  12.  
  13. In article <C0E55F.IK5@csfb1.fir.fbc.com>
  14. jbrock@csfb1.fir.fbc.com (John Brock) writes:
  15.  
  16. >In article <C0CDCz.Co3@csfb1.fir.fbc.com>, jbrock@csfb1.fir.fbc.com (John Brock) writes:
  17. >|> In article <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU>,         Wan Hasan Abdullah <WAN@UTMJB.BITNET> writes:
  18. >|> |> Hello netters!
  19. >|> |>
  20. >|> |> I found that, there's a function to translate all words to upper case
  21. >|> |> but I could'nt find in HELP REXX to form the words from upper case to
  22. >|> |> lower case by using a function. Could anyone help me to solve this
  23. >|> |> problem?
  24. >|> |>
  25. >|> |> Thanks in advance.
  26. >|> |>
  27. >|> |> -WAN-
  28. >|>
  29. >|> How about:
  30. >|>
  31. >|>   lowercase: procedure
  32. >|>   return translate(arg(1), xrange(), translate(xrange()))
  33. >|>
  34. >|> I like this because it is consise and generic.  It should work as it
  35. >|> stands for any language, and it lets me avoid typing out all the upper
  36. >|> and lower case letters by hand (which I think looks ugly, even though
  37. >|> it's clearly more efficient to do it that way).
  38. >
  39. >I'm responding to my own post, as there have been other posts
  40. >expressing concern about this type of procedure translating
  41. >non-alphabetic characters.
  42. >
  43. >On my system at least, all non-alphabetic characters are unchanged by
  44. >the translate function when used with only one argument.  If this isn't
  45. >part of the language definition it ought to be!  In any case you could
  46. >argue that if c ^== translate(c) for any character c, then c by
  47. >definition has a distinct upper case form, and my lowercase function
  48. >makes sense.
  49. >
  50. >It even makes a certain kind of sense if translate is generalized
  51. >(e.g., mapping a ==> b, b ==> c, and c ==> a), an long as it never maps
  52. >two distinct characters to the same character.
  53. >
  54. >Here is a procedure which checks which characters on a given system
  55. >are affected by the translate function:
  56. >
  57. >  x = xrange()
  58. >  y = ""
  59. >
  60. >  do i = 1 to length(x)
  61. >    c = substr(x, i, 1)
  62. >    if c ^== translate(c) then y = y || c
  63. >    end
  64. >
  65. >  say length(y) y
  66. >
  67. >On my (VM/CMS) system this yields:
  68. >
  69. >  26 abcdefghijklmnopqrstuvwxyz
  70. >
  71. >--
  72. >John Brock
  73. >uunet!csfb1!jbrock
  74. >jbrock@csfb1.fir.fbc.com
  75.  
  76. John...this does not work in the general case.  Your "translate(c)"
  77. uses the default translate tables, which are designed to translate only
  78. lower case alphabetic to upper case alphabetic.
  79.  
  80. The input table "xrange('A','Z')" and output table "xrange('a','z')"
  81. are not at all the same.  You certainly will translate "A" (x'C1') to
  82. "a" (x'81'), but you also translate the backslash (x'E0') to the EBCDIC
  83. superscript character (X'A0').  EBCDIC has a lot of characters
  84. (printable and nonprintable) between the letters I and J, as well as
  85. between R and S, which will also get translated.
  86.  
  87. Your technique would work in an ASCII system, bacause all upper-case
  88. alphabetics are in the range X'41'-X'5A' (with no intermixed
  89. characters), and lower-case alphabetics are X'61'-X'7A'.
  90.  
  91. Jim McMaster
  92.