home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19754 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.8 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!ucbvax!EQL.CALTECH.EDU!rankin
  2. From: rankin@EQL.CALTECH.EDU (Pat Rankin)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Help on "simple" EVE/TPU procedure
  5. Message-ID: <921222165417.20400822@EQL.Caltech.Edu>
  6. Date: 23 Dec 92 00:55:36 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 30
  11.  
  12. > I am trying to clean up large amounts of Fortran code which
  13. > contains "junk" in each record of each file, beyond the
  14. > 72-nd character position in each record.
  15. >
  16. > Is it relatively simple to get TPU to truncate each record
  17. > in a file at the 72-nd character position?
  18. > (After that, it would be nice to have TPU delete all
  19. > trailing blanks after the lines of code, but that's not
  20. > as important as the first task.)
  21.  
  22.      It should be pretty simple to do in TPU, or DCL for that matter,
  23. but there are other tools to consider.  You could do it with a one-liner
  24. in awk (well, it's 3 statements but they fit comfortably on 1 line :-).
  25. Using gawk, it would be
  26.  $ gawk "{ $0 = substr($0,1,72); sub(/ +$/,""""); print }" <infile >outfile
  27. (The lump of quotes in the middle is just "" inside a DCL quoted string.)
  28. A more elaborate program could process a whole directory full of files
  29. in a single run.
  30.  
  31.      There's another utility available which is even better suited for
  32. this particular task:  EXTRACT.
  33.  $ extract/columns=(1:72)/edit=(strip_trailing) infile/output=outfile
  34. would do precisely what you're asking for.  It's available via FTP from
  35. hamlet.caltech.edu in [.rankin]extract.vms_share, but you'll need the
  36. VAX FORTRAN compiler to build it.  A slightly older version is avaiable
  37. from the DECUS Fall'90 VAX/L&T SIG tape.  (Warning:  that one had a bug
  38. in the /columns qualifier which is fixed in the vms_share'd sources.)
  39.  
  40.         Pat Rankin, rankin@eql.caltech.edu
  41.  
  42.