home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / rexx / 819 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  3.4 KB

  1. Path: sparky!uunet!gatech!purdue!yuma!csn!stortek!LSTC2VM.stortek.com!SCHMIDT
  2. From: SCHMIDT@LSTC2VM.stortek.com (Jon Schmidt)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Blanks, REXX, and portability...
  5. Message-ID: <16851927C.SCHMIDT@LSTC2VM.stortek.com>
  6. Date: 28 Aug 92 16:24:57 GMT
  7. References: <9208260321.AA05688@SERVER.uwindsor.ca> <ANDERS.92Aug26105620@lise3.lise.unit.no>
  8. Sender: usenet@stortek.com
  9. Organization: StorageTek SW Engineering
  10. Lines: 67
  11.  
  12. In article <ANDERS.92Aug26105620@lise3.lise.unit.no>
  13. anders@lise3.lise.unit.no (Anders Christensen) writes:
  14.   [stuff deleted]
  15. >In ASCII, the following characters are often considered 'whitespace',
  16. >listed in decreasing order of 'whitespaceness' (codes in decimal)
  17. >
  18. >   ascii 32 - space
  19. >   ascii  9 - HT (horizontal tab)
  20. >   ascii 10 - LF (line feed)
  21. >   ascii 13 - CR (carriage return)
  22. >   ascii 12 - NP (new page, or FF - formfeed)
  23. >   ascii 11 - VT (vertical tab)
  24. >
  25. >There might be even more. And worse, in some modes, I think characters
  26. >above 128 are space characters, like hard-space (a space that can not
  27. >be divided between lines).  In particular the HT is considered
  28. >whitespace, since it conceptually a number of compressed space
  29. >characters (customarily 2-8).
  30. >
  31.   [stuff deleted]
  32. >By the way ... I really can't see the problem?  Unix generates tabs
  33. >and spaces as whitespace, the Unix rexx interpreter interprets boths as
  34. >blanks, No problem!
  35.   [stuff deleted]
  36.  
  37. I come from CMS and just recently began using a commercial REXX
  38. interpreter under UNIX.  The manual for this interpreter always
  39. uses words "blank" and "blanks" but never suggests that a blank
  40. might be anything other than a space character.  My meager UNIX
  41. experience had shown than there are some text files where TAB and
  42. SPACE characters are not "equivalent", such as makefiles.  I was
  43. therefore astonished to find that the UNIX REXX expression
  44. ('09'X='20'X) yielded a "true" result.  I later wrote a little
  45. UNIX REXX program (see below) to investigate this anomalous (to me)
  46. phenomenon.  I was shocked to discover that this UNIX REXX
  47. interpreter considered 41 of the 256 possible 8-bit codes in the
  48. range '00'X to 'FF'X to be blanks!  41? Where did this come from?
  49. As an excercise, readers are challenged to write a portable REXX
  50. function that returns the position of the Nth blank within a string,
  51. where N and the string are passed as arguments to the function.
  52.  
  53. Here's my little program, written to explore the commercial UNIX
  54. REXX interpreter's definition and handling of blanks:
  55.  
  56. #!/usr/local/bin/rxx
  57.   blank=LEFT('',1)  /* Get a REXX-defined blank */
  58.   SAY 'Test 1 result:' ('09'X='20'X)                   /* 1 */
  59.   SAY 'Test 2 result:' ('09'X=='20'X)                  /* 0 */
  60.   SAY 'Test 3 result:' (blank='09'X)                   /* 1 */
  61.   SAY 'Test 4 result:' (blank=='09'X)                  /* 0 */
  62.   SAY 'Test 5 result:' (blank='20'X)                   /* 1 */
  63.   SAY 'Test 6 result:' (blank=='20'X)                  /* 1 */
  64.   SAY 'Test 7 result:' COMPARE(blank,'09'X||'20'X)     /* 1 */
  65.   SAY 'Test 8 result:' POS(blank,'09'X||'20'X)         /* 2 */
  66.   SAY 'Test 9 result:' BlankCount(XRANGE('00'X,'FF'X)) /* 41 */
  67.   EXIT 0
  68.   BlankCount:PROCEDURE /* Count blanks in a string */
  69.   nonblanks=0
  70.   DO n=1 TO WORDS(ARG(1))
  71.     nonblanks=nonblanks+WORDLENGTH(ARG(1),n)
  72.     END
  73.   RETURN LENGTH(ARG(1))-nonblanks
  74.  
  75. -- 
  76. Jon_Schmidt@stortek.com  Storage Technology Corporation
  77. (303) 673-3581 - voice   2270 South 88th Street
  78. (303) 673-6039 - fax     Louisville, Colorado 80028-5209
  79.