Question
· Jul 11, 2019

How to delete mutiple RMS files using ##class(%Library.File).ComplexDelete(FILE) with openVMS?

All,

I'm using Cache 2014.1 in an openVMS environment.

If I have multiple RMS files to clean up, for example.

!DIR MEMBER_EXTRACT.*;*

MEMBER_EXTRACT.CSV;2                    MEMBER_EXTRACT.CSV;1
MEMBER_EXTRACT.PROC;1                   MEMBER_EXTRACT.TXT;3
MEMBER_EXTRACT.TXT;2                    MEMBER_EXTRACT.TXT;1

S FILE="MEMBER_EXTRACT.*;*"

Do ##class(%Library.File).ComplexDelete(FILE)

!DIR MEMBER_EXTRACT.*;*
 
MEMBER_EXTRACT.CSV;1                    MEMBER_EXTRACT.TXT;2
MEMBER_EXTRACT.TXT;1
 
Total of 3 files.

What would be the best way to delete all the files using the ComplexDelete class call?
ComplexDelete does't appear to handle the versioning of the RMS files, is this correct?

I know I can whack the files using  S ST=$ZF(-1,"DELETE MEMBER_EXTRACT.*;*") but I was hoping
to accomplish this task without calling out of cache.

Thanks for your help.

Discussion (4)2
Log in or sign up to continue

The ComplexDelete classmethod uses the FileSet query:


ClassMethod ComplexDelete(filename As %String, Output return As %Integer) As %Integer
{
    Set resultset=##class(%ResultSet).%New("%File:FileSet"),return=0
    Do resultset.Execute(..GetDirectory(filename),..GetFilename(filename))
    Set exit=1
    For {
        Quit:'resultset.Next()
        Set file=resultset.Data("Name")
        Set r=$$$FileDeleteRet(file) If r,exit Set exit=0,return=r
    }
    Quit exit
}

The problem is, that query treats ";" as a delimiter separating multiple search patterns.

You could replicate the method but specify another delimiter (e.g. comma) when you Execute the query to get the resultset (untested code):

Do resultset.Execute(..GetDirectory(filename),..GetFilename(filename),,,",")

Maybe someday ISC will enhance ComplexDelete to take an optional delimiter argument.

it looks like only "MEMBER_EXTRACT*" files were touched

!DIR MEMBER_EXTRACT*
 
MEMBER_EXTRACT.CSV;2                    MEMBER_EXTRACT.CSV;1
MEMBER_EXTRACT.DAT;1                    MEMBER_EXTRACT.PROC;3
MEMBER_EXTRACT.PROC;1                   MEMBER_EXTRACT.TXT;3
MEMBER_EXTRACT.TXT;2                    MEMBER_EXTRACT.TXT;1

Total of 8 files.

!DIR *
......
Total of 2932 files.

S FILE="MEMBER_EXTRACT.*;*"
S ST=##class(%Library.File).ComplexDelete(FILE)

W ST
1

!DIR MEMBER_EXTRACT*

MEMBER_EXTRACT.CSV;1                    MEMBER_EXTRACT.PROC;1
MEMBER_EXTRACT.TXT;2                    MEMBER_EXTRACT.TXT;1
 
Total of 4 files.

!DIR *
......
Total of 2928 files.

W 2932-2928
4