HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

reading/writing <CR>s and <FF>s in DCL.

 
SOLVED
Go to solution
Russel Wilmes
Occasional Visitor

reading/writing <CR>s and <FF>s in DCL.


Hi,

I've got a (not very elegant) script that strips formfeeds from a text file and I also need to strip crlfs but can't figure out how to insert the cr in the dcl procedure.

$ open/read infile file1.dat
$ open/write outfile file2.dat
$ read infile line
$ if line .ne. "ctrlL" (meaning a ff) then write outfile line

Our application dumps files with trailing crlfs at the end of every file. ctrl M doesn't insert the cr. I'm using edt but can try another as well. I saw a reference using tpu and some function key sequences but am unfamiliar with tpu.

We're sending these text files to a fax server and they're reciving lots of blank pages on the far end.

Thanks in advance,
Rusty

16 REPLIES
Russel Wilmes
Occasional Visitor

Re: reading/writing <CR>s and <FF>s in DCL.

also, this is on an alpha running vms 7.3-2.
Peter Quodling
Trusted Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

I would definitely consider something a little more powerful the EDT or DCL for attacking this problem (I'll be chastised for that comment, for sure). TPU is far more powerful, Perl (free) is worth considering, and there was a text manipulation language called Scan, which I think may have moved to the freeware archives.

Of course, the most elegant way to do it,is probably in Teco, but those neurons are failing...

It's also not clear what you are looking for. Do you a) want to turn multiple CRLF's into FF's, or b) delete extraneous FFs or c) delete final FF's.

PeterQ
Leave the Money on the Fridge.
Russel Wilmes
Occasional Visitor

Re: reading/writing <CR>s and <FF>s in DCL.


I actually want to find them and strip them. I can find the form feeds no problem, that's a control l into the dcl command procedure that does the reading and writing. i just can't figure out how to get a CR in there. some of the stuff I saw said a ctrl M but that just does a "delete to begnning of line" or somesuch.

I'd love to use perl, however, time is short and my learning curve is steep!
Russel Wilmes
Occasional Visitor

Re: reading/writing <CR>s and <FF>s in DCL.

Or maybe this would be more clear.

When using EDT to create a dcl command procedure...

ctrl [[ =
ctrl l =
? =

Hope that helps...

Thanks again!

Doug Phillips
Trusted Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

To insert any special character with EDT:

PF1 decimal-value-of-charcter PF1 KP3

so for a CR,
press the PF1 key (aka: the gold key)
type 13
press PF1
press the 3 on the keypad.

However, this makes the DCL file look strange when you type it, so you might want to consider instead using a value assignment like:

$ CR[0,8] = %X0D !hex zero D = dec 13

which places the hex value 0D into a symbol named CR.

However, however (;-) there's probably a easier and better way to make the file more fax-friendly.

Doug

Dale A. Marcy
Trusted Contributor
Solution

Re: reading/writing <CR>s and <FF>s in DCL.

$ CR[0,8] = 13 ! Carriage return
$ open/read infile file1.dat
$ open/write outfile file2.dat
$ read infile line
$ line = f$extract(0, f$locate(CR,line), line)
$ if line .ne. "ctrlL" (meaning a ff) then write outfile line


I have just scribbled the above out and have not tested it, but it should truncate the line at the first carriage return in the line. If there is no carriage return in the line, it should leave the line unchanged.
Jan van den Ende
Honored Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

Rusty,

in DCL, you define a symbol to be any ASCI char, by NUMERIC assign of 8 bits.

eg the Escape char (ASCI 27), using ther recognisable symbolname esc:

$ esc[0,8]=27

means "assign value 27 to 8 bits, starting from bit 0, of the symbol esc"

$ bell[0,8]=7 : bell signal

Synyax:
symbol name - (NO spaces!) - left square bracket - offset of first bit - comma - length in bits - right square bracket - equals sihn -
Now to insert it into a string, simply use string concatenation.

$ String = symbol1 + "Litteral" + string2 + string3 (etc...)
or
$ Strng := "''symbol1'litteral''string2'''string3' ..."
(single and double quotes unclear in presentation. Copy / paste into plain-text window for clarity)


Left to do: find ASCI numeric value of desired char.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Russel Wilmes
Occasional Visitor

Re: reading/writing <CR>s and <FF>s in DCL.



Success! Many thanks to all who replied.

I took a roundabout way and am not looking for any carriage returns.

Dales note about using f$locate helped imensely. I'd forgotten about that.

I wanted to strip s and s.

so rather than checking for either two strings just check for existence of

open/read infile file1.dat
open/write outfile file2.dat
top:
read/end=cya infile line
a = f$locate("ctrll",line)
b = f$length(line)
if a .eq. b then write outfile line
goto top
cya:
close infile
close outfile
send file2.dat to fax server!

Still not elegant but it works. At least until our apps folks change the report layout again...

Thanks again!

Eberhard Wacker
Valued Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

Hi, maybe not "elegant" but also a working procedure using the line editor of EDT removing all CRFFs:
$ edit/edt replace.com
then enter therein:

$ edit/edt file1.dat
s///%wh
s///%wh
exit
$ exit

where within edit/edt replace.com
is created with PF1-13-PF1-3
PF1-12-PF1-3

and
PF1-10-PF1-3
if this should be replaced.

Cheers,
EW
David Jones_21
Trusted Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

I can never remember the syntax for bit insertion in DCL, so I use F$FAO("!^") to get a form feed and F$EXTRACT(0,1,F$FAO("!/")) to get a CR (first character of CRLF sequence).
I'm looking for marbles all day long.
William Webb_2
Frequent Advisor

Re: reading/writing <CR>s and <FF>s in DCL.

You could also websearch for a TPU routine (which I believe is attributable to Ken Fairfield) that strips not only and , but all control characters from a text file.

It's especially useful if you have to take the results of a SET HOST/LOG file and turn it into plain text.

If you can't find it, drop me an email first name period middle initial (all my initials are identical) period last name at gmail period com
and I'll send it to tomorrow.
Antoniov.
Honored Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

Hi Rusty,
If you want to remove all CR/LF/FF you can:
$ CR[0,8]=13
$ LF[0,8]=10
$ FF[0,8]=12
$ OPEN/REA SRC INFILE.DAT
$ OPEN/WRITE TGT OUTFILE.DAT
$MLOOP:
$ READ SRC LINE/END=XIT
$ LINE = LINE - CR - LF - FF
$ WRITE TGT LINE
$ GOTO MLOOP
$XIT:
$ CLOSE TGT
$ CLOSE SRC

Antonio Vigliotti
Antonio Maria Vigliotti
Ken Robinson
Valued Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

The above procedure will only work if there is no more that one of each of the characters in each line.

I would write the procedure to use a subroutine to do the actual removing. Something like

$ set noon
$ cr[0,8]=13
$ lf[0,8]=10
$ ff[0,8]=12
$ open/err=nofile inp input_file.txt
$ copy nl: output_file.txt ! create an empty file with better attributes than open/write
$ open/app outp output_file.txt
$rl:
$ read/end=done inp line
$ test_line == line
$ call remove_chars "''cr'"
$ call remove_chars "''lf'"
$ call remove_chars "''ff'"
$ write/sym outp test_line
$ goto rl:
$done:
$ close inp
$ close outp
$ exit
$nofile:
$ write sys$Output "Input file does not exist"
$ exit
$!
$!
$remove_chars: subroutine
$rmloop:
$ if f$loc(p1,test_line) .eq. f$len(test_line) then exit
$ test_line = test_line - p1
$ goto rmloop
$ exit
$endsubroutine
$!

Note: this script is untested and not proofed for errors. I just wrote it.

Ken
William Webb_2
Frequent Advisor

Re: reading/writing <CR>s and <FF>s in DCL.

Here's the TPU procedure- STRIP_TPU.TPU

Apologies to whoever wrote it, as they didn't put their name in comments.

WWWebb
Robert_Boyd
Respected Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

Here is yet another great trick for generating CR and LF:

$ CRLF = F$FAO("!/")
$ CR = F$EXTRACT(0,1,CRLF)
$ LF = F$EXTRACT(1,2,CRLF)

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
Robert_Boyd
Respected Contributor

Re: reading/writing <CR>s and <FF>s in DCL.

Woops -- I got distracted while writing that last line... should be

$ LF = F$EXTRACT(1,1,CRLF)
Master you were right about 1 thing -- the negotiations were SHORT!