[Info-vax] wrong file format
Craig A. Berry
craigberry at nospam.mac.com
Wed Dec 23 16:09:04 EST 2020
On 12/23/20 11:58 AM, Hein RMS van den Heuvel wrote:
> On Wednesday, December 23, 2020 at 11:41:45 AM UTC-5, Michael Moroney wrote:
>> Try the following:
>>
>> $ COPY NL: NEWFILE.DAT
>> $ APPEND OLDFILE.DAT NEWFILE.DAT
>
> Good. The copy command creates an empty default file = variable length sequential file.
>
> Silly, less known, FDL hints
> 1)
> An empty FDL file also defaults to a variable length sequential file.
> Therefor you can use things like: CONVERT/STAT/FDL=NL: OLDFILE.DAT NEWFILE.DAT
>
> 2)
> Instead of an FDL file you can specify an FDL string on most DCL commands.
> For example to create a stream-lf file, you can use:
> $ convert/fdl="record; format stream_lf" OLDFILE.DAT NEWFILE.DAT
> To create a trivial indexed file to play with, with 10 byte key length starting at default byte 0:
> $ create/fdl="file; org ind; key 0; seg0_l 10" tmp.tmp
>
> Back to Philip's question.
>>> I see (in EDT) explicit carriage returns at the end of each line
>
> So maybe we can just make those the terminator and then remove all LF bytes?
> $ set file/att=rfm=stmcr x.x
> now see what you have and deal with it.
>
> I tried removing the linefeeds with simple Perl one liners, but they and up either giving double records per record (one empty) or single record with no terminators. Perl seems to remember stray LF bytes as line end.
>
> You can possibly get there using:
> $ perl -015 -l012 -pe "s/\n//g" nr.tmp > new.tmp
>
> The -015 makes CR the input line terminator
> The -l012 makes LF the output terminator added to each record as defined by the CR's
> The -p adds an implicit simple while loop processing the input stream until EOF
> The -e is an inline script "s/\n//g" telling it to replace any and all LF's in the records to be replaced by nothing.
Phillip's description of the file was:
"The RFM is STM, though as I mentioned EDT sees <CR> at the end of each
non-empty line, and after each such line there is an extra empty line."
Modifying Hein's earlier suggestion, I can reliably create a file that
matches Phillip's description like so:
$ perl -"MVMS::Stdio=vmsopen" -we "$f=vmsopen('>nr.tmp','rfm=stm'); for
(1..3){printf $f qq(%03d\r\n), $_}"
and it can be fixed with the following in-place substitution:
$ perl -pi -e "$_ =~ s/\r\n$//m;" nr.tmp
the "/m" modifier on the substitution matches across line boundaries so
the CRLF and the adjacent EOL (that shows up as a blank line) match and
get removed, and then the print implicit in -p reintroduces the newline
that's been removed.
Sticking with rfm=stmlf or rfm=stmcr rather than just stm would probably
avoid a lot of trouble for reasons Hein explained earlier.
More information about the Info-vax
mailing list