[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

174.0. "Setting longest record length?" by REX::MINOW () Thu Oct 31 1985 18:25

I've written a file compress utility that attempts to preserve vms
file attributes.  However, I can't seem to restore the "longest record
length" value.  The overall sequence is as follows:

Compression:

1. open the input file using FDL$GENERATE to obtain the file
   characteristics.  This does not return the XAB$W_LRL field.
   Write the fdl string to the compressed file.
2. obtain "by hand" the value of XAB$W_LRL and write it to
   the compressed file.
3. write the contents of the file.

Decompression:

1. read the fdl string from the compressed file, create the
   decompressed file using FDL$CREATE.  Close the file.
2. open the file using SYS$OPEN
3. set XAB$W_LRL to the proper value.
4. write the file using SYS$WRITE
5. close the file using SYS$CLOSE.

The contents of XAB$W_LRL are correct at the time SYS$CLOSE is called.

Any ideas are welcome.

Thanks.

Martin.
T.RTitleUserPersonal
Name
DateLines
174.1MARRHQ::RMURPHYFri Nov 01 1985 00:219
You need the XAB LRL field set at $CREATE time (as you have probably guessed).
WAG: Isn't there an ACP function to read/write the file characteristics?
That could be used...
I have some code that does file transfers over async lines that preserves
the characteristics; it opens the input file with a FAB/RAB/XAB combination,
and sends along the characteristics necessary for the corresponding output
file stuff. Written in MACRO; send me MAIL if you're interested in looking
at the code.
	-Rick
174.2LEROUF::HEINFri Nov 01 1985 12:1712
The LRL is 'maintained' by rms, it is not something you should 'set'.

I think LRL=MAX(LRL,RSZ), where RSZ is the record size field in the
RAB being processed by SYS$PUT. I realize now the the basenote mentioned
using SYS$WRITE, not SYS$PUT. Is that right Martin? Are you formatting
records in blocks your-self? maintaining record length fields and all that?
If this is true, and since this is the hackers files, you might want to
try, after you inserted your last record, and while maintaining the
longest seen record yourself; DISCONNECT, CONNECT with RECORD I/O mode
(the default) and to EOF, SYS$PUT anything with length equal to the
max rec len that you found, re-position using the RFA from the PUT,
and TRUNCATE the file, thereby effectivly deleting the dummy 'longest record'.
174.3REX::MINOWFri Nov 01 1985 14:2722
Ayup, I'm writing using sys$write -- since the FDL routines supposedly
transfer the file header stuff, all I need to do is to stuff the bits
onto the disk (I do no interpretation of the data).

Trouble is, FDL doesn't give me the XABFHC LRL field and, as noted,
I haven't found out how to set it myself on a file I didn't create.

The hack in .2 where I add an extra record is going to fail badly if
the decompressed file just fits on the output disk and the longest
record causes it to slop over.

Now, (putting my naive hat on again), the "put" routine must do something
with it's concept of "longest record" AFTER the file is created, and
BEFORE it is closed.  It's this magic -- assuming mere mortals can
understand it -- that I need.

Hmm, perhaps I should sys$put the longest record FIRST, then rewind the
file?

Still confused.

Martin.
174.4R2ME2::GILBERTFri Nov 01 1985 19:418
Have you tried doing a QIO(W) access and deaccess to the file, specifying the
record attribute area as one of the attribute descriptors, and setting the
FAT$W_MAXLEN field to the LRL value you want the file to have?  Just wondering.

Also, instead of using RMS to SYS$WRITE the file contents, you might consider
opening the file (via RMS) with the FAB$V_UFO option (the channel number is
returned in FAB$L_STV), and writing the file with QIO(W)s.  The difference
in overhead is negligable, but more importantly, you have the channel number.
174.5REX::MINOWFri Nov 01 1985 19:4831
Thanks for the help.  I ended up using the hack suggested earlier --
stuffing a dummy "longest" record and rewinding.  The relevant
code is appended -- it should be fairly easy to follow.  If not, you
are welcome join me in longing for the days of RSTS/E and RT11.

Martin.

	r->fab.fab$b_fac =
	    (xab_lrl == 0) ? FAB$M_PUT | FAB$M_BIO
			   : FAB$M_PUT | FAB$M_BRO;
	if ((fdl_status = sys$open(&r->fab)) != RMS$_NORMAL) {
	    return (fail(r, "opening created file", NULL));
	}
	if (xab_lrl != 0) {
	    extern char outbuffer[MAXIO];	/* Handy buffer to use	*/

	    r->rab.rab$l_rop = 0;		/* PUT I/O 		*/
	    if ((fdl_status = sys$connect(&r->rab)) != RMS$_NORMAL)
		return (fail(r, "connect after create, setting length", NULL));
	    r->rab.rab$l_rbf = outbuffer;	/* Put a dummy		*/
	    r->rab.rab$w_rsz = xab_lrl;		/* longest record	*/
	    if ((fdl_status = sys$put(&r->rab)) != RMS$_NORMAL)
		return (fail(r, "putting longest record", NULL));
	    if ((fdl_status = sys$rewind(&r->rab)) != RMS$_NORMAL)
		return (fail(r, "rewinding after long record hack", NULL));
	    if ((fdl_status = sys$disconnect(&r->rab)) != RMS$_NORMAL)
		return (fail(r, "disconnecting after setting length", NULL));
	}
	r->rab.rab$l_rop = RAB$M_BIO;		/* Block I/O only	*/
	if ((fdl_status = sys$connect(&r->rab)) != RMS$_NORMAL)
	    return (fail(r, "connecting after create", NULL));
174.6DIEVMS::HERBERTMon Nov 04 1985 16:524
Longing for the days of RSTS? They are still here.

Kevin Herbert
RSTS/E Development
174.7LEROUF::HEINTue Nov 05 1985 08:1811
Glad to see it worked! Remote brainstorming strikes again :-)

	Should have thought about PUTthe longest record first, and then
	WRITing the real data to the file myself! But then, I did not
	know you knew the LRL while starting to work on the output file.
	
	Martin, You probably do not need the REWIND. An DISCONNECT followed
	by a CONNECT as your code does, will 'rewind' the file for you.
	And on top of that, you could specify the VBN on the first WRITE.

Hein.
174.8REX::MINOWTue Nov 05 1985 19:026
Fixed the "can't create ISAM file bug", thanks to BISTRO::HEIN.
As usual, informal channels are alive and well at Dec.

Thanks for the help.

Martin.