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

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