Page 1 of 1

VMS variable length record file format?

Posted: Thu Sep 04, 2003 4:06 am
by heinvandenheuvel
Any chance for more file formats?!. Textpad seems to do a great job on various stream text files, be they CR, LF or CRLF terminated records.

However, I recently had to look at a file that came in from a VMS system
where the default file format for text files is something called 'variable length record format'. It gave me only the hex format to play with.

It's a pretty simple format. Each record start with a 16 bit little endian count word that indicates the length of that record. The databytes for the record follow that. After that the a 16-bit alligned next length word for the next record. Repeat untill length = -1 or offset = EOF. Minor side rules:

- records always start with the lengthword on an even file offset
- lengths are less than 32768.
- negative lengths indicate a deleted record or end of data in 512 byte block / file. (VMS no-span attribute)

optional format recognition/verification is easy... Just see if there is a 'reasonable' next lenght word on current offset + current length for 3 itterations. Reasonable being: less than 32K, but really more likely less than 255, leaving 0 bytes in odd positions.

Any chance to work on these file in other then binary mode?

Feel free to contact me for details if interested : Hein at hp dot com.

below a perl script that 'converts' such vms file to an NT or Unix file.

Regards,
Hein.

binmode STDIN;
while (read STDIN,$length_word,2) {
# avoid using "S" or "V". just do the math.
($length,$null) = unpack ("CC",$length_word);
$length += $null*256;
last if ($length > 32767);
$read = read STDIN,$line,$length;
print "$line\n";
read STDIN,$null,1 if ($length & 1);
}

Posted: Thu Sep 04, 2003 11:38 am
by jeffy
I know this is not the answer you are looking for, but since you obviously have the talent and knowledge to do so...

Consider using your Perl script to actually convert the file back and forth, VMS-->ASCII, use it in TextPad, ASCII-->VMS.

You could probably make this relatively convenient via two batch scripts, and make that accessible via right-clicking on a file or group of files or directory, and then pressing a key command.

If TextPad were set up to allow binary to be edited, then you could do this easily via two tools (that just call your Perl script). Just open the VMS file, call the VMS-->ASCII tool, switch from binary to ASCII mode (another thing TextPad should be able to do, but can't), edit the file, call the ASCII-->VMS tool and close.

My very unorganized thoughts have now been exhausted. :' )

This is an interesting problem, though. Wonder why TextPad can't handle this format.

Posted: Thu Sep 04, 2003 11:40 am
by jeffy
jeffy wrote:This is an interesting problem, though. Wonder why TextPad can't handle this format.
I should say...I wonder if TextPad could be given some sort of plugin-able interface to accept some not-so-different file formats, such as VMS.

Posted: Thu Sep 04, 2003 11:48 am
by jeffy

Posted: Thu Sep 04, 2003 1:24 pm
by heinvandenheuvel
- Yes, I could script an import/export style task, but that wouldn't help the large community. Then again, maybe I am the only one ever having run into this. It is also easily fixed by using an ftp in ascii mode from vms. But this happened to me when I opened an attached file in a forum, so the file in question never lived on one of my vms systems.

- obviously a file format extension would preferably come in re-useable, extensible kind of way. But I'll take a VMS only solution.

- Thanks for the pointer to the voting questions. I'm a new user here, and while an inspection showed those 5 question for several votes I did not see an easy way to associate them with my post. Know I know.

Cheers,
Hein.

I'd like to see that

Posted: Fri Sep 05, 2003 1:30 am
by Dcantor
I'd certainly like to see a general solution, but would also be happy with a VMS format solution.

(Heck I've already got a TextPad tool written in TECO to remove NUL characters.)