From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
X-Newsgroups: comp.os.vms
Subject: Re: callable PURGE
Date: 27 Apr 1995 00:08:29 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 47
Distribution: world
Message-ID: <3nmn9t$d5v@gap.cco.caltech.edu>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
NNTP-Posting-Host: sol1.gps.caltech.edu
To: Info-VAX@Mvb.Saic.Com
X-Gateway-Source-Info: USENET

In article <26APR199514271239@eql.caltech.edu>, rankin@eql.caltech.edu (Pat Rankin) writes:
=      It should be less overhead on the system to make a single call
=using `filespec;*' plus a confirmation routine which refuses to allow
=deletion of the highest version.  That routine gets passed an RMS FAB,
=which ought to point to a valid NAM--although I haven't verified that
=it actually does--and there's a NAM field which contains a flag bit
=indicating whether or not any higher version numbers of the file exist.
=
=      Disclaimer:  I haven't tested this and take no responsibility if
=you accidentally delete all your files.  :-}

Well, I tried, unsuccessfully, to figure out from the on-line help along how to
get at the NAM block.  Here's a version that doesn't require using the NAM
block, instead relying on the file names generated by LIB$DELETE_FILE:

	SUBROUTINE PURGE(FILESPEC)
	CHARACTER*(*) FILESPEC
	CHARACTER*255 RESULT, OLDFILE
	COMMON /FILE_CONTEXT/ OLDFILE
	EXTERNAL IS_HIGHEST_VERSION
	INTEGER*4 CONTEXT

	CONTEXT = 0
	OLDFILE = '^'
	CALL LIB$DELETE_FILE(';*',FILESPEC,,,,IS_HIGHEST_VERSION,RESULT,
	1	RESULT,CONTEXT)
	RETURN
	END

	INTEGER*4 FUNCTION IS_HIGHEST_VERSION(RESULT)
	CHARACTER RESULT*(*), OLDFILE*255, NEWFILE*255
	COMMON /FILE_CONTEXT/ OLDFILE
	INTEGER*4 STR$COMPARE_EQL, STAT

	CALL STR$ELEMENT(NEWFILE, 0, ';', RESULT)
	IS_HIGHEST_VERSION = STR$COMPARE_EQL(OLDFILE, NEWFILE) .EQ. 0
	OLDFILE = NEWFILE
	RETURN
	END
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.
