home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / rexx / 928 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  3.5 KB

  1. Path: sparky!uunet!gatech!concert!borg!news_server!martinc
  2. From: martinc@grover.cs.unc.edu (Charles R. Martin)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Blanks, REXX, and portability...
  5. Message-ID: <MARTINC.92Sep7194817@grover.cs.unc.edu>
  6. Date: 7 Sep 92 23:48:17 GMT
  7. References: <REXXLIST%92090516060285@UGA.CC.UGA.EDU>
  8.     <MARTINC.92Sep6183949@grover.cs.unc.edu>
  9.     <1992Sep7.163041.1@sejnet.sunet.se>
  10. Sender: news@cs.unc.edu
  11. Organization: UNC Department of Computer Science
  12. Lines: 61
  13. In-reply-to: eric@sejnet.sunet.se's message of 7 Sep 92 16:30:41 GMT
  14.  
  15. In article <1992Sep7.163041.1@sejnet.sunet.se> eric@sejnet.sunet.se (Eric Thomas) writes:
  16.  
  17.    In article <MARTINC.92Sep6183949@grover.cs.unc.edu>, martinc@grover.cs.unc.edu (Charles R. Martin) writes:
  18.    > I think the problem lies in repeated applications of parse, say with
  19.    > columnar fields.  Say I parse the string "ab\tc" -- importing a little C
  20.    > terminology to make clear where the tab lies -- with parse expand.  The
  21.    > tab char should come out to be some number of blanks, as I understand
  22.    > it. (Probably 6 for canonical tabs.)  But if I parse off the first
  23.    > field, THEN parse the resulting "\tc", the tab now wants to expand to 8
  24.    > characters.
  25.  
  26.    Good point, but this is a hasty conclusion. IF you are worried about exact
  27.    column positions and have to cope with data containing tabs and blanks, you
  28.    will have to think carefully in any case. As you pointed out,
  29.  
  30.                    Parse var line a +2 b
  31.                    Parse expand var b <whatever>
  32.  
  33.    will not work, but
  34.                    Parse expand var line a +2 b
  35.                    Parse var b <whatever>
  36.  
  37.    does what you want. If you expand, you have to expand at the source.
  38.    Now, with a REXX that has built-in white space recognition rather
  39.    than expand, the code fragment would have to be:
  40.  
  41.                    Parse var line a +2 b
  42.                    Parse var b <whatever>
  43.  
  44.    The first PARSE gives you a variable 'b' that starts with a tab, the
  45.    second PARSE throws it away (since it is white space) unless you use
  46.    columnar or pattern based parsing. Losing the tab will surely screw
  47.    up your column positioning, since it will yield exactly the same
  48.    result as if the tab had been a blank. So the only way to handle this
  49.    situation properly is to use a form of parsing which does NOT treat
  50.    tabs as white space. You are not making use of the interpreter's
  51.    automatic handling of tabs.
  52.  
  53.    In other words, the situation is not better with a REXX that
  54.    automatically treats tabs as white space; in fact, it is worse.
  55.  
  56. I think I should direct you to the note where I went over precisely what
  57. I meant using regular expressions.  But I think your example is flawed:
  58. once again I don't have a rexx interpreter I trust at hand -- by the
  59. way, OS2 2.0 rexx doesn't recognize the expand clause at all, where does
  60. it come from? -- but would you expect the clause 
  61.  
  62.     parse var b c d
  63.  
  64. to put leading blanks onto the value that shows up in c?  That is, given
  65. b='\b\bX\bY' would you expect c to be "\b\bX"?  That doesn't seem to be
  66. the behavior I have seen so far.
  67. --
  68. Charles R. Martin/(Charlie)/martinc@cs.unc.edu/(ne crm@cs.duke.edu) 
  69. O/Dept. of Computer Science/CB #3175 UNC-CH/Chapel Hill, NC 27599-3175
  70. H/3611 University Dr #13M/Durham, NC 27707/(919) 419 1754
  71. ----------------------------------------------------------------------
  72. "I am he who walks the States with a barb'd tongue, questioning every
  73. one I meet,/Who are you that wanted only to be told what you knew
  74. before?/ Who are you that wanted only a book to join you in your
  75. nonsense?"  _Leaves of Grass_ xxiii.4.
  76.