Operating System - OpenVMS
1748112 Members
3342 Online
108758 Solutions
New Discussion юеВ

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

 
SOLVED
Go to solution
Wim Van den Wyngaert
Honored Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Misunderstood. What is "qw" ? Simply a string ?

Wim
Wim
Ataikili
Frequent Advisor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Hi Wim,
"qw" only a string.
i used it instead of CRLF in my file.
Now i transfer my file with ftp(ascii mode) to vms AND ready to convert "qw" with CRLF.

i cant find any replace function...
As want to strip "qw" and add CRLF to same offset
Wim Van den Wyngaert
Honored Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

$loop:
$ pos=f$loc("qw",rec)
$ len=f$len(rec)
$ if pos .lt. len
$ then
$ rec=f$extr(0,pos-1,rec)+ cr + lf + f$extr(pos+2,len-pos-1)
$ goto loop
$ endif

Wim (untested)
Wim
Hein van den Heuvel
Honored Contributor
Solution

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

The principle look good Wim butI think you have the offsets wrong. Like you indicated... it was untested.

$crlf = F$FAO("!/")
$loop:
$qw = F$LOCATE("qw",record)
$IF qw.EQ.F$LEN(record) THEN GOTO no_more_qw
$record = f$extract(0,qw,record) + crlf + f$extract(qw+2,999,record)
$GOTO loop
$no_more_qw:


Here is an other for the now much simplyfied problem:
Just use a TPU script.

-------------- replace.tpu ----------------
procedure replace_qw_by_crlf
local string_range;
loop;
string_range := search('qw',forward);
exitif string_range = 0;
position(beginning_of(string_range));
erase(string_range);
copy_text(ascii(13));
copy_text(ascii(10));
endloop;
exit;
endprocedure;

replace_qw_by_crlf;
write;
exit;
----------------------------------

$ edit/tpu/nodisplay/command=replace.tpu /out=

fwiw,
Hein.
Guenther Froehlin
Valued Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Ataikili,

you want to get a file in a format so FASTWIRE 'eats' it? Well, how does the format of a file written by FASTWIRE look like (DUMP/RECORD)?

Then we can tell you how it may be composed on the Windows side or, how your FTPed file can be transformed on the OpenVMS side.

One thing to keep in mind with OpenVMS file atrributes is that "Record attributes: Carriage return carriage control" means if that file is presented on a terminal or printer an extra CR/LF is output to the device. But this CR/LF IS NOT IN THE FILE!!!

/Guenther
Wim Van den Wyngaert
Honored Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Yes Hein, it's wrong. f$loc starts from 0 not 1 (not my kind of stuff, I lived in cobol).

But removing the 999 easy solution :
$ set ver
$@wim.lis !execution now starts
$rec="abcqwdefg"
$cr="1"
$lf="2"
$
$loop:
$ pos=f$loc("qw",rec)
$ len=f$len(rec)
$ if pos .lt. len
$ then
$ rec=f$extr(0,pos,rec)+ cr + lf + f$extr(pos+2,len-pos,rec)
$ goto loop
$loop:
$ pos=f$loc("qw",rec)
$ len=f$len(rec)
$ if pos .lt. len
$ endif
$ sh symb rec
REC = "abc12defg"

fwiw

Wim (will write 1 page with "I will not post untested code")
Wim
Ataikili
Frequent Advisor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

I fixed it.
Can't solve with only FTP but
FTP+TELNET(running a dcl scrit)

These are my champions,
Hein van den Heuvel(VMS)
Michael Phelp(Swimming)
Usain Bolt(Athletics)

Thanks Hein a lot,
and sure Wim, Schweda and others

Best Regards To ALL From ISTANBUL
Jon Pinkley
Honored Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Hein,

I liked your tpu procedure approach, so I copied it and tried it with the following input file:

QWqwQwqW

Record number 1 (00000001), 8 (0008) bytes, RFA(0001,0000,0000)

0A0D0A0D 0A0D0A0D ................ 000000

So, it appears that the tpu search builtin is case insensitive. So it wouldn't be appropriate if "QW", "Qw" or "qW" should not be translated to crlf. A somewhat cursory look at the tpu documentation didn't reveal how to make the search be an exact match. I tried specifying an /init file with "SET FIND CASE EXACT" in it, but that didn't change the behavior of the search.

Jon
it depends
Jon Pinkley
Honored Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

The dump output above was from the output file.

The input file had the four case variations of QW, and all were converted to crlf, not just the all lowercase version.
it depends
Doug Phillips
Trusted Contributor

Re: how can i read a sequential rms file and write it to a sequential variable lenght rms file

Jon,

Add EXACT to the search command:

string_range := search('qw',forward,EXACT);