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

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