Page 2 of 2

HP Basic Reverse file read

Posted: Tue Feb 28, 2023 6:32 pm
by kwfeese
I'm trying to read a file in reverse using HP Basic and I came across this paragraph in Guide to OpenVMS File Applications:

8.4.3 Processing Indexed Files
Indexed files provide the most record-processing flexibility. Your program can read existing records from the file in sequential, random access by RFA mode or random access by key mode. RMS also allows you to write any number of new records into an indexed file if you do not violate a specified key constraint, such as not allowing duplicate key values.

In random access by key mode, RMS provides two forward search key options for use with one of four match options (see Section 8.4.3.2). A reverse search key option permits reverse random access when used in combination with either of the two forward search key options.

There was an example but it was written in C and, unfortunately, my current company doesn't have a C license.

Has anyone ever accomplished this and if so can you provide examples?

Re: HP Basic Reverse file read

Posted: Wed May 03, 2023 9:49 pm
by arne_v
Maybe it makes sense to think of RFA as a bookmark to be used to get quickly back where one has been before.

Re: HP Basic Reverse file read

Posted: Mon Jul 31, 2023 4:57 pm
by neilrieck
I've got a bunch of BASIC demos posted here. Some of them include accessing data via key.

https://neilrieck.net/demo_vms_html/ope ... index.html

Caveats:
  1. the industry refers to indexed RMS files by the generic name of ISAM (indexed sequential access method)
  2. unlike SQL, you can't just say I want data in reverse order. The Indexed RMS file must have already have a descending key (BASIC and COBOL allowed you to do this directly; other languages like C required you to do it with system call). However, you could also create a temp file with a reverse key, read the data into the temp file, then access the temp file normally (in reverse order). Believe it or not, this is how SQL engines do it when a reverse index hasn't been created.
  3. one of my BASIC demos opens then displays sys$system:SYSUAF.DAT 8-)

Re: HP Basic Reverse file read

Posted: Mon Jul 31, 2023 10:28 pm
by hein
>> you can't just say I want data in reverse order.

Yes you can. Using the REV bit. Me and Elinor thought it would be a neat thing to offer and she implemented it for 7.3-2 if i recall correctly. Within bucket it is easy to see how one could just return the record before the last one right? But what if you get to the beginning of bucket? There is no back pointer, only a next. Well, use the index above e. Up, left, down, last. Recurse as needed.

>>> The Indexed RMS file must have already have a descending key

No it doesn't. See above.

;-)

Hein