csc@NCSC.ARPA (Murray) (05/20/88)
I need to know if there is a system utility in VMS for getting the number of the last record in a sequential and an indexed file. The only way that we have found so far is to read the file from beginning to end to find how many records are in the file. Please answer through the address norm@ncsc.arpa. NORM.
LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (05/24/88)
I need to know if there is a system utility in VMS for getting the number of the last record in a sequential and an indexed file. The only way that we have found so far is to read the file from beginning to end to find how many records are in the file. There is no general solution to this. VMS does not keep track of "record numbers" at all, much less of the LAST record number. For sequential files with fixed-length records, you can determine the total length of the file from the highest block and byte values (available from RMS) and divide by the record length. For other kinds of sequential files, unless you record the number yourself, only reading and counting will work. For indexed files, this isn't even a particularly meaningful concept. Indexed files are ordered along one or more keys, in addition to being laid out in some physical order within the file. Do you want the record number of the physically-last record, or the record number of the logically-last record along key 0, or key 1, or what? I suspect that you may have something very different from the "record number", as I interpret the words, in mind; for example, the last block allocated, or the last block used. The former can be gotten easily for any file - see the documentation of the File Header Characteristic XAB in the RMS manual; it's the HBK field. The latter is the EBK field in the same XAB, but beware: it is meaningful ONLY for sequential files. If "last record" means something else to you, my blind guess would be that the information is not stored by RMS, hence not available unless you make it available yourself. -- Jerry