[comp.os.vms] UTILITY TO TRUNCATE TRAILING BLACKS... REVISITED...

xrjjm%scint.span@JPL-VLSI.ARPA (07/23/87)

Comment:   Begin User Supplied Mail Headers.
*Site:     NASA Goddard Space Flight Center - Greenbelt, Maryland, USA.
*Position: 76 Deg. 52' 28.5" West, 38 Deg. 59' 59.8" North.
*From:     John J. McMahon, Systems Programmer, STX - ST Systems Corporation.
*Project:  COBE Science Data Room (CSDR), Code 401.1
*Reply-To: (Arpa-Internet)       XRJJM%CSDR.SPAN@JPL-VLSI.ARPA [Old Format]
*Reply-To: (Arpa-Internet)       XRJJM%CSDR.SPAN@VLSI.JPL.NASA.GOV [New Format]
*Reply-To: (Bitnet)              ZMJJM@SCFVM
*Reply-To: (Span/Physnet/Hepnet) 6173::XRJJM = CSDR::XRJJM (Node 6.29)
*Reply-To: (TEXnet)              UTADNX::UTSPAN::CSDR::XRJJM

X> From: uunet!mnetor!utzoo!utgpu!water!watmath!julian!peter@seismo.css.gov
X> 
X> Is there a utility for VMS that truncates trailing blanks from a fixed line
X> length file?  On our Tops-10 system we did it with PIP.  I was hoping for a
X> switch to type or copy or convert, but I can't see anything.
X> 
X> Peter Marshall, Data Comm. Manager
X> CCS, U. of Western Ontario, London, Canada N6A 5B7

Hi... I'm a hacker... and I'm here to help...  (I figured I would get my two
cents in on the "hacker" commentary).

Well, first for your information... COPY does have a /TRUNCATE qualifier.
However that doesn't do what you want.  /TRUNCATE will truncate the file
at the end-of-file, as opposed to the end-of-allocation.

One possibility, which may help, is to use the Lexical fuction 'F$EDIT'.
F$EDIT has an argument called "TRIM" which "Removes leading and trailing
spaces and tabs from the string." (VMS DCL Dictionary, V4.4, Page DCL-358).

What you can do is something like the following (In a command procedure):

$ OPEN/READ F1 <file to be trucated>
$ OPEN/WRITE F2 <Output File>
$ Loop:
$ Read/End_Of_File=X F1 Dataline
$ Dataline_T = F$Edit(Dataline,"TRIM")
$ Write F2 Dataline_T
$ Goto Loop
$ X:
$ Close F1
$ Close F2

(This is not a tested procedure, I just created it in the Mail Editor)

Now the problem with this is that the leading blanks and tabs will also be
removed.  This may not be what you want...

Regards,
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
John J. McMahon (Fast-Eddie)                     
Disclaimer: Views expressed in this letter are my own, 
            and are not meant to represent the views of my employers.

SYSRUTH@UTORPHYS.BITNET (07/24/87)

There is a DEC utility on our VAX 11/780 called TRUNCATE. I am not
sure whether it requires RSX emulation or not; we always run it
via MCR TRUNCATE but then I do that a lot with programs in sys$system
(e.g. SYSGEN, NCP). It does exactly what you want - trims off blank
space *at the end* of each line. It is the utility we use (infrequently)
to read cards into a file. It prompts for input and output file names.

I just checked and it is not on our uVAXes, so it may be a part of
RSX emulation (a layered product, natch).

Ruth Milner
Systems Manager
SYSRUTH@UTORPHYS (BITNET)