Find no-longer-relevant waves in Current Data Folder

Here is a utility I created to remedy my poor coding practices. I often use a pxp as a stating point for a modified version with different purpose or code structure, without being careful to kill unnecessary waves, as new waves are created. This code finds waves in the Data Browser's current data folder that are not created in any of the specified Procedure files. It lists their names and sizes, but does NOT kill them, since useful waves may have been imported. It has been tested in Windows 10 using the root data folder.

Function CheckWaves() //    find and list wvs not mentioned in any procedure window
    String mytext= ProcedureText("",-1,"Procedure")+ProcedureText("",-1,"Setup")+ProcedureText("",-1,"Propagate")
    // a long text of specified procedures used to search for wvs  
    String list=WaveList("*",";","") // all waves in CDF   
    String separator = ";"
    Variable separatorLen = strlen(separator)
    Variable numItems = ItemsInList(list)
    Variable offset = 0
    string item
    variable vSize
    Variable i
    for(i=0; i<numItems; i+=1)
        // When using offset, the index parameter is always 0
        item = StringFromList(0, list,separator,offset)
        vSize = NumberByKey("SIZEINBYTES",WaveInfo($item,0))/1000 // in KBytes
        if(strsearch(mytext,item, -1,2)==-1) // not found in procedures
            print item, vSize, strsearch(mytext,item, -1,2) // item not in not in any proc window
        endif
        offset += strlen(item) + separatorLen
    endfor
End

You should modify the "mytext" specification, which concatenates the specified procedures to be searched, or pass their string variables into the function.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More