source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_ShowDataTree.ipf @ 1242

Last change on this file since 1242 was 1242, checked in by srkline, 3 years ago

updating the IgorVersion? pragma to v7.0 for all files to be consistent.

File size: 3.9 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3#pragma IgorVersion = 7.00
4
5
6//
7// This is a copy (wtih slight modifications) of the DataFolderTree_SRK.ipf file
8// which itself is from Igor Exchange (see below)
9//
10// it is modified to look for VSANS files, and ignore the DAS_log folder if possible
11// since it's not part of the file I'm concerned with during reduction.
12//
13//
14
15////////
16// see the help entry for IndexedDir for help on (possibly) how to do this faster
17// -- see the function Function ScanDirectories(pathName, printDirNames)
18//
19
20
21// from IgorExchange On July 17th, 2011 jtigor
22// started from "Recursively List Data Folder Contents"
23// Posted July 15th, 2011 by hrodstein
24
25Proc V_ShowDataFolderTree(dataFolderStr, level, sNBName)
26//      String dataFolderStr="root:"
27        String dataFolderStr="root:Packages:NIST:VSANS:RawVSANS:"
28        Variable level=0
29        String sNBName="DataFolderTree"
30       
31        V_ListDataFolder($dataFolderStr, level, sNBName)
32
33
34end
35
36// ListDataFolder(dfr, level)
37// Recursively lists objects in data folder.
38// Pass data folder path for dfr and 0 for level.
39// Example: ListDataFolder(root:, 0, "NoteBook")
40//Start with sNBName = "" to print to history
41Function V_ListDataFolder(dfr, level, sNBName)
42        DFREF dfr
43        Variable level                  // Pass 0 to start
44        String sNBName
45 
46        String name
47        String sString
48 
49        if (level == 0)
50                name = GetDataFolder(1, dfr)
51                sPrintf sString, "%s (data folder)\r", name
52                V_WriteBrowserInfo(sString, 1, sNBName)
53        endif
54 
55        Variable i
56 
57        String indentStr = "\t"
58        for(i=0; i<level; i+=1)
59                indentStr += "\t"
60        endfor
61 
62        Variable numWaves = CountObjectsDFR(dfr, 1)
63        for(i=0; i<numWaves; i+=1)
64                name = GetIndexedObjNameDFR(dfr, 1, i)
65//              Print "wave type = ",WaveType(dfr:$name,1)              //1=numeric, 2=text
66                if(WaveType(dfr:$name,1) == 1)
67                        WAVE w=dfr:$name
68                        if(numpnts(w) > 0)              //the Igor_Folder_Attributes wave has zero points, catch the error
69//                              sPrintf sString, "%s%s (wave) %g\ttyp=%g\r", indentStr, name, w[0], WaveType(w)
70                                sPrintf sString, "%s%s   \t%g\r", indentStr, name, w[0]
71                        else
72                                sPrintf sString, "%s%s (wave)\r", indentStr, name
73                        endif
74                else
75                        WAVE/T wt=dfr:$name             // text wave is assumed...
76//                      sPrintf sString, "%s%s (wave) \"%s\"\ttyp=text\r", indentStr, name, wt[0]
77                        sPrintf sString, "%s%s   \t\"%s\"\r", indentStr, name, wt[0]
78                endif
79                V_WriteBrowserInfo(sString, 2, sNBName)
80        endfor 
81 
82        Variable numNumericVariables = CountObjectsDFR(dfr, 2) 
83        for(i=0; i<numNumericVariables; i+=1)
84                name = GetIndexedObjNameDFR(dfr, 2, i)
85                sPrintf sString, "%s%s (numeric variable)\r", indentStr, name
86                V_WriteBrowserInfo(sString, 3, sNBName)
87        endfor 
88 
89        Variable numStringVariables = CountObjectsDFR(dfr, 3)   
90        for(i=0; i<numStringVariables; i+=1)
91                name = GetIndexedObjNameDFR(dfr, 3, i)
92                sPrintf sString, "%s%s (string variable)\r", indentStr, name
93                V_WriteBrowserInfo(sString, 4, sNBName)
94        endfor 
95 
96        Variable numDataFolders = CountObjectsDFR(dfr, 4)       
97        for(i=0; i<numDataFolders; i+=1)
98                name = GetIndexedObjNameDFR(dfr, 4, i)
99                if(cmpstr(name,"DAS_logs") != 0)                //ignore DAS_log folder
100                        sPrintf sString, "%s%s (data folder)\r", indentStr, name
101                        V_WriteBrowserInfo(sString, 1, sNBName)
102                        DFREF childDFR = dfr:$(name)
103                        V_ListDataFolder(childDFR, level+1, sNBName)
104                endif
105        endfor 
106 
107//when finished walking tree, save as RTF with dialog   
108        if(level == 0 && strlen(sNBName) != 0)
109                SaveNotebook /I /S=4  $sNBName
110        endif
111End
112 
113Function V_WriteBrowserInfo(sString, vType, sNBName)
114        String sString
115        Variable vType
116        String sNBName
117 
118        if(strlen(sNBName) == 0)
119                print sString
120                return 0
121        endif
122        DoWindow $sNBName
123        if(V_flag != 1)
124                NewNoteBook/F=1 /N=$sNBName /V=1 as sNBName
125        else
126                DoWindow/F $sNBName
127        endif
128        Notebook $sNBName selection={endOfFile, endOfFile}
129        if(vType == 1)//wave
130                Notebook $sNBName fstyle=1
131                Notebook $sNBName text=sString
132                Notebook $sNBName fstyle=-1
133        else
134                Notebook $sNBName text=sString 
135        endif
136 
137End
138
Note: See TracBrowser for help on using the repository browser.