Operating System - OpenVMS
1753745 Members
5036 Online
108799 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