A Function to Compare DFREF Values
jjweimer
DFREF cdf, xdf
cdf = GetDataFolderDFR()
xdf = GetWavesDataFolderDFR(xwave)
if (cmpDFR(cdf,xdf)==0)
same two data folders
else
two different data folders
endif
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
DFREF xdf = root:test:mydata
print cmpDFR(cdf, xdf) ==> 2
print cmpDFR(xdf, cdf) ==> -2
In the mean time, you can probably make do with something like this:
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
April 17, 2009 at 03:00 pm - Permalink
Thanks. I was not aware of DataFolderRefStatus().
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 19, 2009 at 07:28 pm - Permalink
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:
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.
April 22, 2009 at 09:20 am - Permalink
Sounds good. Thanks for the suggested code and the changes in Igor to support it!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 22, 2009 at 11:37 am - Permalink
Update: In 6.2, I added two functions: WaveRefsEqual(w1,w2) and DataFolderRefsEqual(dfr1,dfr2).
April 2, 2010 at 07:41 am - Permalink