A Function to Compare DFREF Values

The new DFREF functions are useful. Unless I am mistaken, we might also need a cmpDFR function to check them, otherwise we still have to use the non-DFREF functions. For example ...

    DFREF cdf, xdf
    cdf = GetDataFolderDFR()
    xdf = GetWavesDataFolderDFR(xwave)
    if (cmpDFR(cdf,xdf)==0)
         same two data folders
    else
         two different data folders
    endif


It would also be useful for cmpDFR to return the level of the first ABOVE the second, for example root: is two levels above root:test:mydata, so ...

    DFREF cdf = root:
    DFREF xdf = root:test:mydata
    print cmpDFR(cdf, xdf)  ==> 2
    print cmpDFR(xdf, cdf) ==> -2
I've added this to my list to investigate.

In the mean time, you can probably make do with something like this:
Function EqualDFR(df1,df2)
    DFREF df1,df2
   
    if( DataFolderRefStatus(df1) == 0 || (DataFolderRefStatus(df1) != DataFolderRefStatus(df2)) )
        return 0
    endif
    DFREF dfSav= GetDataFolderDFR()
    SetDataFolder df1
    String df1path= GetDataFolder(1)
    SetDataFolder df2
    String df2path= GetDataFolder(1)
    SetDataFolder dfSav
   
    return CmpStr(df1path,df2path) == 0
end


Larry Hutchinson wrote:
I've added this to my list to investigate. ...


Thanks. I was not aware of DataFolderRefStatus().

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
As I was investigating this, I added an optional data folder ref parameter to GetDataFolder:
GetDataFolder( mode, [dfr])
If the optional Data Folder dfr is present, it is used in place of the current data folder.


Given that, the EqualDFR user function above is simplified like so:
Function EqualDFR(df1,df2)
    DFREF df1,df2
 
    if( DataFolderRefStatus(df1) == 0 || (DataFolderRefStatus(df1) != DataFolderRefStatus(df2)) )
        return 0
    endif
 
    return CmpStr(GetDataFolder(1,df1),GetDataFolder(1,df2)) == 0
end


So, I think that rather than cluttering the function list, I'll just leave it as is.

Larry Hutchinson wrote:
....
So, I think that rather than cluttering the function list, I'll just leave it as is.


Sounds good. Thanks for the suggested code and the changes in Igor to support it!

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH