Operating System - OpenVMS
1753768 Members
5721 Online
108799 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
Russel Wilmes
New Member

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 16
Russel Wilmes
New Member

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
New Member

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
New Member

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
New Member

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