|VMS Replace Command [message #72631]
||Fri, 08 August 2003 11:14
Registered: October 1999
I'm trying to create a DCL command which will parse out a file, by replacing the ~'s in the file with a combination of a carriage return/line feed.|
Currently, my file is on one line and is thousands of characters long.
test~32House~young~three~ .......and so on
so the file would look like:
I need to separate thousands of these segments and it is all being passed on one line.
Here is what I tried:
$open/read ifile ‘p1’
$open/write ofile 'f$parse(‘p1’,,,"NAME")'.dat
$read/end=end ifile rec
$ A = REC
$ cnt = 1
$ B = f$locate("~",A)
$ write sys$output b
$ a'cnt' = f$element(0,"~",a)
$ A = f$extract(b+1,f$length(A)-B,A)
$ WRITE OFILE a'cnt'
$ if b .eqs. f$length(A) then goto more
$ cnt = cnt+1
$ write ofile A
$ goto loop
This seems to work, but throughout the file, I get blank lines and sometimes the file breaks at the wrong spot and not at the ~
Any ideas on what I'm doing wrong, or how I can write a replace command in DCL to do this?
I need to be able to do this in an automated fashion, and not manually.