Operating System - OpenVMS
1827854 Members
1576 Online
109969 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
Ataikili
Frequent Advisor

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

I want to create a sequential variable lenght rms file that has carriage return carriage control.

Hein's offer a dcl script that can put CRLF inside file and this is first step for me.

$ crlf = f$fao("!/")
$ create/fdl=nl: test.tmp ! FDL is optional really, all defaults applied
$ open/write test test.tmp
$ write test "EUROPA",crlf,"AFRICA"
$ write test "AMERICA"
$ close test
$ type test.tmp

this creates a rms file with record format VCF

i want it sequential variable lenght.

And i want to create it from reading a file(that come from xp-dos with ftp) and write to file(that i want)

I need a dcl that reads a file record by record
until end of file and write to another file.

Who can propose a dcl script for it.
30 REPLIES 30
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

Replace
open/write
by
open/append

Wim
Wim
Hein van den Heuvel
Honored Contributor

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

btw... You don't have to close topic and re-open when the discussion is pretty much a continuation.

Anyway... here is what I tried to reply to the FTP topic, but it close, and it seems to apply here:

FTP is going to be a little tricky, because of the cr-lf. On the dos side, and in an ascci file transfer, at the cr-lf is undistinguishable from a new line.
Fortunately the data is well recognizable.

So on the OpenVMS side you could process the ascii text and glue everything together unless it starts with "14-spaces and a tab followed by 6 numbers and a tab". SMOP. Send money and we'll do it :-).

I would look at delivering the file with 'codes' for cr-lf and ff (and tab optionally). The PERL/C style escapes might do (\r \f \t ...) but since this is OpenVMS, why not use the Formatted Ascii Output directives.
Check out: help lexi f$fao directive

For example, the first two lines as generated on Windoze could be:

HA050501390004
A000026 !_020508!_0033848!/0062!_00440!_842!/0139!_99999.999.!/NORM!_12000!_4!_RPS!_N!/TEST!/!/!_TEST!/SEN METAL END.VE SAN.TI
C.LTD.STI!/TR41000139007C0030712BL001!_7350477692!_G!/ALICI TEST!^0139999990033848

(all together, I also used !_ for for this forum presentation).

Now feed this into a DCL script

----- Formatter.com ----

$if p2.eqs."" then exit
$close/nolog in
$close/nolog out
$open/error=done in 'p1
$create 'p2
$open/append out 'p2
$loop:
$read/end=done in record
$write out f$fao(record)
$goto loop
$done:
$close/nolog in
$close/nolog out
$exit
--------------------

Use as: @formatter.com test.dat test.out

When I do this, the DUMP/RECORD for test.out gives EXACTLY the same bytes you attached in the dump.

Good luck!
Hein.

Ataikili
Frequent Advisor

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

Wim,
What you suggested ?
is it convert my file from VCF to variable lenght record format ?
Hein van den Heuvel
Honored Contributor

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


If the 'damge is already done' then you can just convert the DCL generated VFC-PRN file to a 'normal' sequential file using:

$CONVERT/FDL=NL: dcl.txt normal.txt

Yes, that's right. An 'empty' FDL file has all the default to make a normal file.

Enjoy,
Hein.
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

I meant that create by default creates variable record length file. Then with the procedure of Hein you add records to it. Result is variable record length file.

So,

create new.dat
open/append x neww.dat
open/read o old.dat
b:
read/end=e o o_rec
write x o_rec
goto b
e:
close x
close o

Not sure what your file contains. Maybe you have to split o_rec.

Wim

BTW : my file transfer from dos to vms gives correct results.
Wim
Ataikili
Frequent Advisor

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

new.dat and old.dat must be parametric to run it because filename will continue like that batch_0001 batch_0002
so i did tried heins one... it run but do nothing :)
Ataikili
Frequent Advisor

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

Hein i wrote belows into a file with a name mm.com

$if p2.eqs."" then exit
$close/nolog in
$close/nolog out
$open/error=done in 'p1
$create 'p2
$open/append out 'p2
$loop:
$read/end=done in record
$write out f$fao(record)
...

here what is p2 and 'p2
and is (record) means my record or it is only a keyword ?
Ataikili
Frequent Advisor

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

Hein p1 param1(input file), p2(ouput file)
that is okey but with ' it understand it is a veriable??
Jon Pinkley
Honored Contributor

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

RE"new.dat and old.dat must be parametric to run it because filename will continue like that batch_0001 batch_0002
so i did tried heins one... it run but do nothing :)"

What exactly did you try? The formatter or the create/fdl=nl:?

The formatter works given the input hein provided (you will have to remove a line wrap from the input file).

Hein's proposal is about as straight forward as you can get. If you can't work with that, you need to hire someone to write the programs.
it depends
Ataikili
Frequent Advisor

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

Pinkley i think you can't understand the question.
From this code i suppose p1 p2 are the params containing filenames .

Because i can't see filenames inside code but only in run command."@formatter.com fileinp fileoutput".
So i think it can be the variables of filenames.

VMS is only a $ sign for me. Beginner is an expert for me...

I want only 2-3 tricky clues for my question.

You only wasting my time with this comment...
Hein van den Heuvel
Honored Contributor

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

>> here what is p2 and 'p2
and is (record) means my record or it is only a keyword ?

p1 through p8 are 'automatic' names for command file arguments.

>> Hein p1 param1(input file), p2(ouput file) that is okey but with ' it understand it is a veriable??

You can use typed in text there, or used variable substitutions: 'your-variable-for-filename'

If this is part of a larger script, then I would just embed the core of the code, and not stick it in a seperated command files.

Untested/unfished hint:

$file_loop:
$close/nolog in
$close/nolog out
$inname = f$search("input*.dat")
$if infile.eqs."" then exit
$outname = f$parse(inname,,,"name") + ".out"
$open/error=file_loop in 'inname
$create 'outname
$open/append out 'outname
$record_loop:
$read/end=file_loop in record
$write out f$fao(record)
$goto record_loop

or...


$ i = 0
$file_loop:
$ i = i + 1
$close/nolog in
$close/nolog out
$name = f$fao("batch_!4ZL",i)
$inname = name + ".dat"
$outname = name + ".out"
$open/error=done in 'inname
$create 'outname
$open/append out 'outname
$record_loop:
$read/end=file_loop in record
$write out f$fao(record)
$goto record_loop
$done:
$write "Done. Could not open file: " inname
$exit

Happy learnings,
Hein.
Hein van den Heuvel
Honored Contributor

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

Ataikili,

I think you have send me an Email just now, but it landed in my spam folder, and I hit the permanent delete button before reading.
Please resend if it is something you feel you can not ask here.

Hein.

Ataikili
Frequent Advisor

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

Hi Heuvel,
I resend it again.
Sure i can ask here but i want speed up the job.
Today i asked 5-6 question(some of them sure not valid questions...) and got 2 valid answer in 8 hours :)
Steven Schweda
Honored Contributor

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

> Today i asked 5-6 question(some of them
> sure not valid questions...) and got 2
> valid answer in 8 hours :)

Better questions might help considerably.
Starting three threads for one problem was
probably not optimal, either.
Ataikili
Frequent Advisor

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

Mr. Schweda
You are absolutely right.
And as i wrote i cant recognise the true question.
As you know i guessed i can find the solution inside ftp and asked first question for ftp :)
and then asked for creating rms...
I have also users for my applications and lots of the questions nonsense:)
So i never think their questions nonsense.if they can ask it better way sure they can solve it...

Thanks for your helps
Ataikili
Frequent Advisor

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

Hein , Wim
Thanks for your replies.
I understand some of what you means at 01:38 AM :)

But still it seems only a tip of iceberg

Ongoing...

Kindly regards
Phil.Howell
Honored Contributor

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

what didn't work when you tried the zip, ftp, unzip method?
Ataikili
Frequent Advisor

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

Hi Phil,
Sure i used ftp with optimum mode and create a file. But not absolutely solved my question.
I think i am near my solution now :)

Now i have a sequential file that has variable lenght record format with cr control=carriage control.

Yes everythink is okey last step is;
i want to replace all "qw" strings with CRLF
in my file.
i tried with f$parse, f$string, f$locate
but i cant find true solution.
$ crlf = f$fao("!/")
$.............
pls fill in the blanks :)
thanks
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

cr[0,7]=13
lf[0,7]=10
rec = rec - cr -lf (may be in a loop until all cr gone)

Wim
Wim
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