[Info-vax] Example of random access by record number on an RMS fixed record size, relative organization file?

T. Kurt Bond tkurtbond at gmail.com
Mon Sep 18 03:00:02 EDT 2023


"T. Kurt Bond" <tkurtbond at gmail.com> wrote:
> Does anybody have an example program that uses random access by record
> number on an RMS fixed record size, relative organization file they'd be
> willing to share?  I'm missing something, probably something obvious,
> but I've not been able to get random access by record number to work.
> I'm working in VAX MACRO (on VMS 5.5-2), but should be able to use an
> example in any language.

I should definitely have provided more context with my question.

I'm debugging VTIL, a VAX MACRO implementation of a Forth-like language
that I wrote in 1988.  I lost the source long ago (it was saved on a
9-track tape, and probably copied later to an 8mm tape, but when we
converted the VAX to use the Charon-VAX emulator I didn't get it copied
over to some other format, alas), so I retyped it from a printout that
recently turned up, and unfortunately in the process introduced a lot of
bugs through typos.

VTIL includes Forth-style block I/O words (words are Forth's version of
functions) that allow the user to load specificed numeric 1024-byte
blocks from a file, change their contents, and write them back out.
Unfortunately, the file was created by a different program (also written
in MACRO), and that program was *not* included in the printout.  The
VTIL example program that used the block I/O words was an editor that
stored its text in blocks.  (Probably inspired by the editor in
*Starting Forth*.)  That program was also lost.

The code in VTIL itself which opend the file only specified the block
size, that the records were fixed, and random access was done using the
block number as the key.  It didn't specify the organization.  I
*thought* the file was created using relative organization, but when I
tried to load a block it would fail with a message about the key being
invalid, even though when I looked at the longword in memory with the
number in it it was correct.  I wrote a couple of MACRO and BASIC
programs to play around with RMS files.  Still confused, I posted here.

After reading all your replies (and thank you very much) and considering
the examples provided and reading more in the RMS Reference Manual and
doing a lot of searches in that manual I figured out two things: (1) you
can do random access to a *sequential* file as long as the records are
fixed size, and (2) I'd misspelled the KBF argument to the $RAB macro as
KFB.  Sigh.  (SO MANY TYPOS.)

Once I knew those things I was easily able to create a macro program
(MAKE-VTILBLOCKS.MAR) to create the sequential file and write an
appropriate number of blocks to it, another (READ-VTILBLOCKS.MAR) that
was able to randomly access records in it and display bytes from them.
Once that worked I fixed the typo in VTIL.MAR and then I was able to
read a block from the block file!  Then I wrote a test VTIL program to
load a block from the block file, display a byte from it, change a byte
in it, and store the updated block back in the file in such a way that
READ-VTILBLOCKS could display that byte and easily confirm it had been
updated correctly.

The VTIL repository on GitHub is https://github.com/tkurtbond/VTIL
if anyone is interested in looking at the code.

Direct links to MAKE-VITLBLOCKS.MAR:

    https://github.com/tkurtbond/VTIL/blob/a547c6af02e8fdd8ee4cf31cd2c081437d163554/make-vtilblocks.mar#L1

and to READ-VITLBLOCKS.MAR:

    https://github.com/tkurtbond/VTIL/blob/a547c6af02e8fdd8ee4cf31cd2c081437d163554/read-vtilblocks.mar#L1

and the line in VTIL.MAR with the typo:

    https://github.com/tkurtbond/VTIL/blob/a547c6af02e8fdd8ee4cf31cd2c081437d163554/vtil.mar#L438

Thanks again for your help!
-- 
T. Kurt Bond, tkurtbond at gmail.com, tkurtbond.github.io, consp.org, & tkb.tx0.org



More information about the Info-vax mailing list