Recursively List Data Folder Contents
hrodstein
// ListDataFolder(dfr, level)
// Recursively lists objects in data folder.
// Pass data folder path for dfr and 0 for level.
// Example: ListDataFolder(root:, 0)
Function ListDataFolder(dfr, level)
DFREF dfr
Variable level // Pass 0 to start
String name
if (level == 0)
name = GetDataFolder(1, dfr)
Printf "%s\r", name
endif
Variable i
String indentStr = "\t"
for(i=0; i<level; i+=1)
indentStr += "\t"
endfor
Variable numWaves = CountObjectsDFR(dfr, 1)
for(i=0; i<numWaves; i+=1)
name = GetIndexedObjNameDFR(dfr, 1, i)
Printf "%s%s (wave)\r", indentStr, name
endfor
Variable numNumericVariables = CountObjectsDFR(dfr, 2)
for(i=0; i<numNumericVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 2, i)
Printf "%s%s (numeric variable)\r", indentStr, name
endfor
Variable numStringVariables = CountObjectsDFR(dfr, 3)
for(i=0; i<numStringVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 3, i)
Printf "%s%s (string variable)\r", indentStr, name
endfor
Variable numDataFolders = CountObjectsDFR(dfr, 4)
for(i=0; i<numDataFolders; i+=1)
name = GetIndexedObjNameDFR(dfr, 4, i)
Printf "%s%s (data folder)\r", indentStr, name
DFREF childDFR = dfr:$(name)
ListDataFolder(childDFR, level+1)
endfor
End
// Recursively lists objects in data folder.
// Pass data folder path for dfr and 0 for level.
// Example: ListDataFolder(root:, 0)
Function ListDataFolder(dfr, level)
DFREF dfr
Variable level // Pass 0 to start
String name
if (level == 0)
name = GetDataFolder(1, dfr)
Printf "%s\r", name
endif
Variable i
String indentStr = "\t"
for(i=0; i<level; i+=1)
indentStr += "\t"
endfor
Variable numWaves = CountObjectsDFR(dfr, 1)
for(i=0; i<numWaves; i+=1)
name = GetIndexedObjNameDFR(dfr, 1, i)
Printf "%s%s (wave)\r", indentStr, name
endfor
Variable numNumericVariables = CountObjectsDFR(dfr, 2)
for(i=0; i<numNumericVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 2, i)
Printf "%s%s (numeric variable)\r", indentStr, name
endfor
Variable numStringVariables = CountObjectsDFR(dfr, 3)
for(i=0; i<numStringVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 3, i)
Printf "%s%s (string variable)\r", indentStr, name
endfor
Variable numDataFolders = CountObjectsDFR(dfr, 4)
for(i=0; i<numDataFolders; i+=1)
name = GetIndexedObjNameDFR(dfr, 4, i)
Printf "%s%s (data folder)\r", indentStr, name
DFREF childDFR = dfr:$(name)
ListDataFolder(childDFR, level+1)
endfor
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
// Recursively lists objects in data folder.
// Pass data folder path for dfr and 0 for level.
// Example: ListDataFolder(root:, 0, "NoteBook")
//Start with sNBName = "" to print to history
Function ListDataFolder(dfr, level, sNBName)
DFREF dfr
Variable level // Pass 0 to start
String sNBName
String name
String sString
if (level == 0)
name = GetDataFolder(1, dfr)
sPrintf sString, "%s (data folder)\r", name
WriteBrowserInfo(sString, 1, sNBName)
endif
Variable i
String indentStr = "\t"
for(i=0; i<level; i+=1)
indentStr += "\t"
endfor
Variable numWaves = CountObjectsDFR(dfr, 1)
for(i=0; i<numWaves; i+=1)
name = GetIndexedObjNameDFR(dfr, 1, i)
sPrintf sString, "%s%s (wave)\r", indentStr, name
WriteBrowserInfo(sString, 2, sNBName)
endfor
Variable numNumericVariables = CountObjectsDFR(dfr, 2)
for(i=0; i<numNumericVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 2, i)
sPrintf sString, "%s%s (numeric variable)\r", indentStr, name
WriteBrowserInfo(sString, 3, sNBName)
endfor
Variable numStringVariables = CountObjectsDFR(dfr, 3)
for(i=0; i<numStringVariables; i+=1)
name = GetIndexedObjNameDFR(dfr, 3, i)
sPrintf sString, "%s%s (string variable)\r", indentStr, name
WriteBrowserInfo(sString, 4, sNBName)
endfor
Variable numDataFolders = CountObjectsDFR(dfr, 4)
for(i=0; i<numDataFolders; i+=1)
name = GetIndexedObjNameDFR(dfr, 4, i)
sPrintf sString, "%s%s (data folder)\r", indentStr, name
WriteBrowserInfo(sString, 1, sNBName)
DFREF childDFR = dfr:$(name)
ListDataFolder(childDFR, level+1, sNBName)
endfor
//when finished walking tree, save as RTF with dialog
if(level == 0 && strlen(sNBName) != 0)
SaveNotebook /I /S=4 $sNBName
endif
End
Function WriteBrowserInfo(sString, vType, sNBName)
String sString
Variable vType
String sNBName
if(strlen(sNBName) == 0)
print sString
return 0
endif
DoWindow $sNBName
if(V_flag != 1)
NewNoteBook/F=1 /N=$sNBName /V=1 as sNBName
else
DoWindow/F $sNBName
endif
Notebook $sNBName selection={endOfFile, endOfFile}
if(vType == 1)//wave
Notebook $sNBName fstyle=1
Notebook $sNBName text=sString
Notebook $sNBName fstyle=-1
else
Notebook $sNBName text=sString
endif
End
July 17, 2011 at 05:19 pm - Permalink