source: sans/Dev/trunk/NCNR_User_Procedures/USANS/Main_USANS.ipf @ 393

Last change on this file since 393 was 377, checked in by srkline, 15 years ago

Added menu option to all 3 templates for "Check for Updates". Includes for each template now include the FTP procedure file.

Added a condition to CheckIfRawData? (NCNR_Utils) to look for very small files. Small files (cleanout.txt is 2 bytes) were moving past EOF and displaying an error dialog.

  • Property eol-style set to native
File size: 36.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma Version=2.21
3#pragma IgorVersion=6.0
4
5//********************
6// 101101 Vers. 1
7//
8// Main initialization procedures for USANS reduction
9// initializes globals and oflders
10// draws the main panel for user interaction
11// action procedures for the USANS_Panel
12//
13//
14//
15// 09 NOV 04 vers 1.1
16// - updated dOmega and dQv
17// - write out dQv to 6-column data sets for analysis compatibility
18//
19//
20//********************
21
22Menu "USANS"
23        "USANS Reduction Panel",ShowUSANSPanel()
24        "Build USANS Notebook"
25        "Desmear USANS Data",Desmear()
26        "-"
27        "Load USANS Data",U_LoadOneDData()
28        "Convert to 6 Columns",Convert3ColTo6Col()
29        "-"
30        "Feedback or Bug Report",U_OpenTracTicketPage("")
31        "Check for Updates",CheckForLatestVersion()
32End
33
34// Bring the USANS_Panel to the front
35// ALWAYS initializes the folders and variables
36// then draws the panel if necessary
37//
38Proc ShowUSANSPanel()
39        //version number
40        Variable/G root:USANS_RED_VERSION=2.21                  //distribution as of Jan 2007
41       
42        Init_MainUSANS()
43        DoWindow/F USANS_Panel
44        if(V_Flag==0)
45                USANS_Panel()
46        Endif
47End
48
49// initializes the folders and globals for use with the USANS_Panel
50// waves for the listboxes must exist before the panel is drawn
51// "dummy" values for the COR_Graph are set here
52// instrumental constants are set here as well
53//
54Proc Init_MainUSANS()
55        NewDataFolder/O root:Globals
56        NewDataFolder/O/S root:Globals:MainPanel
57       
58        Make/O/T/N=1 fileWave,samWave,empWave,curWave //Added curWave Sept 06 A. Jackson
59        fileWave=""
60        samWave=""
61        empWave=""
62        curWave="" //Added Sept 06 A. Jackson
63        //Wave for handling Current Data AJJ Sept 06
64        Make/O/N=1 SAMisCurrent,EMPisCurrent
65        SAMisCurrent = 0
66        EMPisCurrent = 0
67        Make/O/T/N=5 statusWave=""
68        Make/O/B/U/N=1 selFileW
69        Make/O/B/U/N=1 cselFileW
70        //for the graph control bar
71        Variable/G gTransWide = 1
72        Variable/G gTransRock = 1
73        Variable/G gEmpCts = 0.76                       //default values as of 15 DEC 05 J. Barker
74        Variable/G gBkgCts = 0.62                       //default values as of 15 DEC 05 J. Barker
75        Variable/G gThick = 0.1
76        Variable/G gTypeCheck=1
77        //Text filter for data files AJJ Sept 06
78        String/G FilterStr
79        Variable/G gUseCurrentData = 0
80       
81        SetDataFolder root:
82       
83        NewDataFolder/O root:RAW
84        NewDataFolder/O root:SAM
85        NewDataFolder/O root:COR
86        NewDataFolder/O root:EMP
87        NewDataFolder/O root:BKG
88        NewDataFolder/O root:SWAP
89        NewDataFolder/O root:Graph
90       
91        //dummy waves for bkg and emp levels
92        Make/O root:EMP:empLevel,root:BKG:bkgLevel
93        root:EMP:empLevel := root:Globals:MainPanel:gEmpCts             //dependency to connect to SetVariable in panel
94        root:BKG:bkgLevel := root:Globals:MainPanel:gBkgCts
95       
96        //INSTRUMENTAL CONSTANTS
97        Variable/G  root:Globals:MainPanel:gTheta_H = 3.9e-6            //Darwin FWHM   (pre- NOV 2004)
98        Variable/G  root:Globals:MainPanel:gTheta_V = 0.014             //Vertical divergence   (pre- NOV 2004)
99        //Variable/G  root:Globals:MainPanel:gDomega = 2.7e-7           //Solid angle of detector (pre- NOV 2004)
100        Variable/G  root:Globals:MainPanel:gDomega = 7.1e-7             //Solid angle of detector (NOV 2004)
101        Variable/G  root:Globals:MainPanel:gDefaultMCR = 1e6            //factor for normalization
102       
103        //Variable/G  root:Globals:MainPanel:gDQv = 0.037               //divergence, in terms of Q (1/A) (pre- NOV 2004)
104        Variable/G  root:Globals:MainPanel:gDQv = 0.117         //divergence, in terms of Q (1/A)  (NOV 2004)
105
106       
107
108End
109
110//draws the USANS_Panel, the main control panel for the macros
111//
112
113Window USANS_Panel() : Panel
114        PauseUpdate; Silent 1           // building window...
115        NewPanel /W=(600,44,1015,493)/K=1 as "USANS_Panel"
116        SetDrawLayer UserBack
117        SetDrawEnv fstyle= 1
118        DrawText 12,53,"Data Files"
119        SetDrawEnv fstyle= 1
120        DrawText 157,192,"Empty Scans"
121        SetDrawEnv fstyle= 1
122        DrawText 154,54,"Sample Scans"
123        DrawLine 6,337,398,337
124        DrawLine 5,33,393,33
125        SetDrawEnv fstyle= 1
126        DrawText 140,357,"Raw Data Header"
127        SetDrawEnv fstyle= 1
128        DrawText 293,55,"Current Data"
129        ListBox fileLB,pos={5,55},size={110,230},proc=FileListBoxProc
130        ListBox fileLB,listWave=root:Globals:MainPanel:fileWave
131        ListBox fileLB,selWave=root:Globals:MainPanel:selFileW,mode= 4
132        ListBox samLB,pos={149,55},size={110,90},listWave=root:Globals:MainPanel:samWave
133        ListBox samLB,mode= 1,selRow= -1
134        Button ClearSamButton,pos={224,148},size={35,21},proc=ClearButtonProc,title="Clr"
135        Button ClearSamButton,help={"Clears the list of sample scans"}
136        Button ClearEmpButton,pos={227,286},size={35,20},proc=ClearButtonProc,title="Clr"
137        Button ClearEmpButton,help={"Clears the list of empty scans"}
138        Button RefreshButton,pos={9,310},size={104,20},proc=RefreshListButtonProc,title="Refresh"
139        Button RefreshButton,help={"Refreshes the list of raw ICP data files"}
140        Button DelSamButton,pos={186,148},size={35,20},proc=DelSamButtonProc,title="Del"
141        Button DelSamButton,help={"Deletes the selected file(s) from the list of sample scans"}
142        Button DelEmpButton,pos={190,286},size={35,20},proc=DelEmpButtonProc,title="Del"
143        Button DelEmpButton,help={"Deletes the selected file(s) from the list of empty scans"}
144        ListBox empLB,pos={151,194},size={110,90}
145        ListBox empLB,listWave=root:Globals:MainPanel:empWave,mode= 1,selRow= 0
146        Button toSamList,pos={118,55},size={25,90},proc=toSamListButtonProc,title="S->"
147        Button toSamList,help={"Adds the selected file(s) to the list of sample scans"}
148        Button toEmpList,pos={120,195},size={25,90},proc=toEmptyListButtonProc,title="E->"
149        Button toEmpList,help={"Adds the selected file(s) to the list of empty (cell) scans"}
150        ListBox StatusLB,pos={11,358},size={386,77}
151        ListBox StatusLB,listWave=root:Globals:MainPanel:statusWave
152        Button pickPathButton,pos={6,8},size={80,20},proc=PickBT5PathButton,title="DataPath..."
153        Button pickPathButton,help={"Select the data folder where the raw ICP data files are located"}
154        Button PlotSelectedSAMButton,pos={148,148},size={35,20},proc=PlotSelectedSAMButtonProc,title="Plot"
155        Button PlotSelectedSAMButton,help={"Plot the selected sample scattering files in the COR_Graph"}
156        Button PlotSelectedEMPButton,pos={152,286},size={35,20},proc=PlotSelectedEMPButtonProc,title="Plot"
157        Button PlotSelectedEMPButton,help={"Plot the selected empty cell scattering files in the COR_Graph"}
158        Button pickSavePathButton,pos={97,8},size={80,20},proc=PickSaveButtonProc,title="SavePath..."
159        Button pickSavePathButton,help={"Select the data folder where data is to be saved to disk"}
160        Button USANSHelpButton,pos={341,6},size={50,20},proc=USANSHelpButtonProc,title="Help"
161        Button USANSHelpButton,help={"Show the USANS reduction help file"}
162        Button RefreshCurrent,pos={298,310},size={95,20},proc=RefreshCurrentButtonProc,title="Refresh",disable=2
163        Button RefreshCurrent,help={"Updates data files on Charlotte and gets current data file name"}
164        Button AddCurToSAM,pos={264,55},size={25,90},proc=CurtoSamListButtonProc,title="<-S",disable=2
165        Button AddCurToSAM,help={"Adds the current data file to the list of sample scans"}
166        Button AddCurToEMP,pos={265,194},size={25,90},proc=CurtoEmptyListButtonProc,title="<-E",disable=2
167        Button AddCurToEMP,help={"Adds the current data file to the list of empty scans"}
168        ListBox CurFileBox,pos={295,55},size={100,230},proc=FileListBoxProc,disable=1
169        ListBox CurFileBox,listWave=root:Globals:MainPanel:curWave,mode=1
170        SetVariable FilterSetVar,pos={8,289},size={106,18},title="Filter",fSize=12
171        SetVariable FilterSetVar,value= root:Globals:MainPanel:FilterStr
172        CheckBox UseCurrentData,pos={298,290},size={10,10},proc=UseCurrentDataProc,title="Enable Current Data"
173        CheckBox UseCurrentData,value=0
174        Button USANSFeedback,pos={220,6},size={100,20},proc=U_OpenTracTicketPage,title="Feedback"
175       
176EndMacro
177
178
179
180//draws a simple graph of the monitor counts, transmission counts, and detector counts
181// plots the selected raw data file when "plot raw" is selected from the USANS_Panel
182//
183Proc GraphRawData()
184        PauseUpdate; Silent 1           // building window...
185        String fldrSav= GetDataFolder(1)
186        SetDataFolder root:RAW:
187        //String textStr = StringForRawGraph()
188        //textStr=StringByKey("FILE",textStr,":",";")+" MONRATE:"+num2str(mean(MonCts)/NumberByKey("TIMEPT",textStr,":",";"))
189        Display /W=(600,525,1015,850)/L=left1/B=bottom1 /K=1 DetCts vs Angle as "Raw Data"
190        ModifyGraph margin(top)=50
191        //Display /W=(600,525,1015,850) /K=1 DetCts vs Angle as "Raw Data"
192        DoWindow/C RawDataWin
193        //AppendToGraph/L=left1 /B=bottom1 DetCts vs Angle
194        AppendToGraph/L=left2/B=bottom1 TransCts vs Angle
195        AppendToGraph/L=left3/B=bottom1 MonCts vs Angle
196        SetAxis/A/N=2 left1
197        SetAxis/A/N=2 left2
198        SetAxis/A/N=2 left3
199        ModifyGraph mode=4, marker=19
200        ModifyGraph rgb(TransCts)=(1,4,52428),rgb(MonCts)=(1,39321,19939)
201        ModifyGraph msize=1,grid=1,mirror=2,standoff=1,lblPos=50,tickUnit=1,notation=1,freePos={0.1,kwFraction}
202        ModifyGraph nticks(left2)=2
203        ModifyGraph nticks(left3)=2
204        ModifyGraph mirror(bottom1)=0
205        ModifyGraph axisEnab(left1)={0.1,0.5},gridEnab(left1)={0.1,1}
206        ModifyGraph axisEnab(left2)={0.57,0.77},gridEnab(left2)={0.1,1}
207        ModifyGraph axisEnab(left3)={0.8,1},gridEnab={0.1,1}
208        ModifyGraph axisEnab(bottom1)={0.1,1},gridEnab(bottom1)={0.1,1}
209        ErrorBars DetCts Y,wave=(ErrDetCts,ErrDetCts)
210        TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Angle"
211        TextBox/F=0/O=90/E=2/A=LC/X=2/N=text2 "Counts"
212        //TextBox/N=text1/A=RC/X=0.50/Y=-2 textStr
213        //Label bottom1 "Angle (degrees)"
214        Label left1 " "
215        Label left2 " "
216        Label left3 " "
217        TitleForRawGraph()
218        SetDataFolder fldrSav
219End
220
221// plots the selected EMP files onto the COR_Graph
222// Does the following:
223// - loads raw data
224// - normalizes counts to time and 1E6 monitor counts
225// sorts by angle
226// finds zero angle (and peak height)
227// converts to q-values
228// finds T wide
229// updates the graph
230//
231Function PlotSelectedEMPButtonProc(ctrlName) : ButtonControl
232        String ctrlName
233
234        //get selected files from listbox (everything)
235        //use the listBox wave directly
236        Wave/T listW=$"root:Globals:MainPanel:empWave"
237        //Wave for indication of current data set AJJ Sept 2006
238        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
239        Variable ii,num=numpnts(listW)
240        String fname="",fpath="",curPathStr=""
241        PathInfo bt5PathName
242        fpath = S_Path
243        PathInfo bt5CurPathName
244        curPathStr = S_Path
245               
246        if(cmpstr("",listW[0])==0)
247                return(0)               //null item in 1st position, exit
248        Endif
249       
250        //load, normalize, and append
251        //loop over the number of items in the list
252        for(ii=0;ii<num;ii+=1)
253               
254                //Check to see if file is current data set AJJ Sept 06
255                if (isCurrent[ii] ==  1)
256                        fname = curPathStr + listw[ii]
257                else
258                        fname = fpath + listw[ii]
259                endif
260
261               
262                LoadBT5File(fname,"SWAP")       //overwrite what's in the SWAP folder
263                Convert2Countrate("SWAP")
264                if(ii==0)       //first time, overwrite
265                        NewDataWaves("SWAP","EMP")
266                else            //append to waves in "EMP"
267                        AppendDataWaves("SWAP","EMP")
268                endif
269        endfor
270        //sort after all loaded
271        DoAngleSort("EMP")
272       
273        //find the peak and convert to Q-values
274        Variable zeroAngle = FindZeroAngle("EMP")
275        if(zeroAngle == -9999)
276                DoAlert 0,"Couldn't find a peak - using zero as zero angle"
277                zeroAngle = 0
278        Endif
279        ConvertAngle2Qvals("EMP",zeroAngle)
280       
281        //find the Trans Cts for T_Wide
282        FindTWideCts("EMP")
283       
284        //copy the data to plot to the root:Graph directory, and give clear names
285        if(WaveExists($("root:EMP:Qvals")))
286                Duplicate/O $("root:EMP:Qvals"),$("root:Graph:Qvals_EMP")
287        Endif
288        Duplicate/O $("root:EMP:Angle"),$("root:Graph:Angle_EMP")
289        Duplicate/O $("root:EMP:DetCts"),$("root:Graph:DetCts_EMP")
290        Duplicate/O $("root:EMP:ErrDetCts"),$("root:Graph:ErrDetCts_EMP")
291       
292        //now plot the data (or just bring the graph to the front)
293        DoCORGraph()
294End
295
296// plots the selected SAM files onto the COR_Graph
297// Does the following:
298// - loads raw data
299// - normalizes counts to time and 1E6 monitor counts
300// sorts by angle
301// finds zero angle (and peak height)
302// converts to q-values
303// finds T wide
304// updates the graph
305//
306Function PlotSelectedSAMButtonProc(ctrlName) : ButtonControl
307        String ctrlName
308
309        //get selected files from listbox (everything)
310        //use the listBox wave directly
311        Wave/T listW=$"root:Globals:MainPanel:samWave"
312        //Wave for indication of current data set AJJ Sept 2006
313        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
314        Variable ii,num=numpnts(listW)
315        String fname="",fpath="",curPathStr=""
316        PathInfo bt5PathName
317        fpath = S_Path
318        PathInfo bt5CurPathName
319        curPathStr = S_Path
320       
321        if(cmpstr("",listW[0])==0)
322                return(0)               //null item in 1st position, exit
323        Endif
324       
325        //load, normalize, and append
326        //loop over the number of items in the list
327        for(ii=0;ii<num;ii+=1)
328                fname = fpath + listw[ii]
329               
330                //Check to see if file is current data set AJJ Sept 06
331                if (isCurrent[ii] ==  1)
332                        fname = curPathStr + listw[ii]
333                else
334                        fname = fpath + listw[ii]
335                endif
336                               
337                LoadBT5File(fname,"SWAP")       //overwrite what's in the SWAP folder
338                Convert2Countrate("SWAP")
339                if(ii==0)       //first time, overwrite
340                        NewDataWaves("SWAP","SAM")
341                else            //append to waves in "SAM"
342                        AppendDataWaves("SWAP","SAM")
343                endif
344        endfor
345        //sort after all loaded
346        DoAngleSort("SAM")
347       
348        //find the peak and convert to Q-values
349        Variable zeroAngle = FindZeroAngle("SAM")
350        if(zeroAngle == -9999)
351                DoAlert 0,"Couldn't find a peak - using zero as zero angle"
352                zeroAngle = 0
353        Endif
354        ConvertAngle2Qvals("SAM",zeroAngle)
355        //find the Trans Cts for T_Wide
356        FindTWideCts("SAM")
357        //
358        //copy the data to plot to the root:Graph directory, and give clear names
359        if(WaveExists($("root:SAM:Qvals")))
360                Duplicate/O $("root:SAM:Qvals"),$("root:Graph:Qvals_SAM")
361        Endif
362        Duplicate/O $("root:SAM:Angle"),$("root:Graph:Angle_SAM")
363        Duplicate/O $("root:SAM:DetCts"),$("root:Graph:DetCts_SAM")
364        Duplicate/O $("root:SAM:ErrDetCts"),$("root:Graph:ErrDetCts_SAM")
365       
366        //now plot the data (or just bring the graph to the front)
367        DoCORGraph()
368End
369
370//sort the data in the "type"folder, based on angle
371//carry along all associated waves
372//
373Function DoAngleSort(type)
374        String type
375       
376        Wave angle = $("root:"+Type+":Angle")
377        Wave detCts = $("root:"+Type+":DetCts")
378        Wave ErrdetCts = $("root:"+Type+":ErrDetCts")
379        Wave MonCts = $("root:"+Type+":MonCts")
380        Wave TransCts = $("root:"+Type+":TransCts")
381       
382        Sort Angle DetCts,ErrDetCts,MonCts,TransCts,Angle
383        return(0)
384End
385
386// converts to countrate per 1E6 monitor counts (default value)
387// by dividing by the counting time (reported in header in seconds per point)
388// and the globally defined monitor count
389//
390// works on data in "type" folder
391//
392// note that trans detector counts are NOT normalized to 1E6 mon cts (not necessary)
393//
394Function Convert2Countrate(type)
395        String type
396       
397        String noteStr = note($("root:"+Type+":DetCts"))
398        Variable ctTime
399        ctTime = NumberByKey("TIMEPT",noteStr,":",";")
400        //normalize by counting time
401        Wave detCts = $("root:"+Type+":DetCts")
402        Wave ErrdetCts = $("root:"+Type+":ErrDetCts")
403        Wave MonCts = $("root:"+Type+":MonCts")
404        Wave TransCts = $("root:"+Type+":TransCts")
405       
406        detCts /= ctTime
407        ErrDetCts /= ctTime
408        MonCts /= ctTime
409        TransCts /= ctTime
410       
411        //normalize to monitor countrate [=] counts/monitor
412        //trans countrate does not need to be normalized
413        NVAR defaultMCR=root:Globals:MainPanel:gDefaultMCR
414        DetCts /= monCts/defaultMCR
415        ErrDetCts /= MonCts/defaultMCR
416       
417        //adjust the note (now on basis of 1 second)
418        ctTime = 1
419        noteStr = ReplaceNumberByKey("TIMEPT",noteStr,ctTime,":",";")
420        Note/K detCts
421        Note detCts,noteStr
422       
423        return(0)
424End
425
426
427// copies data from one folder to another
428//
429// used for the first set, simply obliterate the old waves in the folder
430//
431Function NewDataWaves(fromType,toType)
432        String fromType,toType
433       
434        Duplicate/O $("root:"+fromType+":Angle"),$("root:"+toType+":Angle")
435        Duplicate/O $("root:"+fromType+":DetCts"),$("root:"+toType+":DetCts")
436        Duplicate/O $("root:"+fromType+":ErrDetCts"),$("root:"+toType+":ErrDetCts")
437        Duplicate/O $("root:"+fromType+":MonCts"),$("root:"+toType+":MonCts")
438        Duplicate/O $("root:"+fromType+":TransCts"),$("root:"+toType+":TransCts")
439       
440        //check for qvals wave, move if it's there
441        if(WaveExists($("root:"+fromType+":Qvals")))
442                Duplicate/O $("root:"+fromType+":Qvals"),$("root:"+toType+":Qvals")
443        Endif
444       
445End
446
447//to add additional data to a folder, need to concatenate the data in the waves
448//and need to update the wave note associated with "DetCts" to include the additional file
449//
450Function AppendDataWaves(fromType,toType)
451        String fromType,toType
452       
453        String fromNote="",toNote="",newNote="",fromfile="",toFile=""
454       
455        ConcatenateData( ("root:"+toType+":Angle"),("root:"+fromType+":Angle") ) //appends "from" at the end of "to"
456        ConcatenateData( ("root:"+toType+":DetCts"),("root:"+fromType+":DetCts") )
457        ConcatenateData( ("root:"+toType+":ErrDetCts"),("root:"+fromType+":ErrDetCts") )
458        ConcatenateData( ("root:"+toType+":MonCts"),("root:"+fromType+":MonCts") )
459        ConcatenateData( ("root:"+toType+":TransCts"),("root:"+fromType+":TransCts") )
460       
461
462        //adjust the wavenote, to account for the new dataset
463        fromNote = note($("root:"+fromType+":DetCts"))
464        fromFile = StringByKey("FILE",fromNote,":",";")
465        toNote = note($("root:"+toType+":DetCts"))
466        toFile = StringByKey("FILE",toNote,":",";")
467        toFile += "," + fromfile
468        toNote = ReplaceStringByKey("FILE",toNote,toFile,":",";")
469        Note/K $("root:"+toType+":DetCts")
470        Note $("root:"+toType+":DetCts"),toNote
471       
472        Return(0)
473End
474
475// action procedure to select the raw data path where the bt5 files are located
476//
477Function PickBT5PathButton(PathButton) : ButtonControl
478        String PathButton
479       
480        //Print "DataPathButton Proc"
481        Variable err = PickBT5Path()            //=1 if error
482
483End
484
485//pick the data folder to save the data to - in general must be a local disk, not the ICP database....
486//
487Function PickSaveButtonProc(ctrlName) : ButtonControl
488        String ctrlName
489       
490        NewPath/O/M="SAVE data to the selected folder" savePathName
491        PathInfo/S savePathName
492        String dum = S_path
493        if (V_flag == 0)
494                return(1)
495        else
496                return(0)               //no error
497        endif
498End
499
500// Show the help file, don't necessarily keep it with the experiment (/K=1)
501Function USANSHelpButtonProc(ctrlName) : ButtonControl
502        String ctrlName
503       
504        DisplayHelpTopic/Z/K=1 "USANS Data Reduction"
505        if(V_flag !=0)
506                DoAlert 0,"The USANS Data Reduction Help file could not be found"
507        endif
508        return(0)
509End
510
511//prompts user to choose the local folder that contains the BT5 Data
512//only one folder can be used, and its path is bt5PathName (and is a NAME, not a string)
513//this will overwrite the path selection
514//returns 1 if no path selected as error condition
515Function PickBT5Path()
516       
517        NVAR isChecked = root:Globals:MainPanel:gUseCurrentData
518       
519        //set the global string to the selected pathname
520        NewPath/O/M="pick the BT5 data folder" bt5PathName
521        PathInfo/S bt5PathName
522        String dum = S_path
523        if (V_flag == 0)
524                //Path does not exist
525                return(1)
526        else
527                if (isChecked == 1)
528                        NewPath/O/M="Select Current Data" bt5CurPathName, getCurrentPath(S_Path)
529                        return(0)               //no error
530                Endif
531        endif
532End
533
534//action procedure to load and plot a raw data file
535// loads the data based on selected file and bt5pathname
536// draws a new graph if necessary
537// otherwise just updates the data
538//
539Function PlotRawButtonProc(ctrlName) : ButtonControl
540        String ctrlName
541
542        String fname=""
543       
544        if (cmpstr(ctrlName,"FileLB") == 0)
545                //Print "PlotRaw Button"
546                //take the selection, and simply plot the counts vs. angle - don't save the data anyplace special
547                //get the selected wave
548                Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
549                Wave sel=$"root:Globals:MainPanel:selFileW"
550                Variable ii=0,num=numpnts(sel),err
551
552               
553                PathInfo bt5PathName
554                fname = S_Path
555                do
556                        if(sel[ii] == 1)
557                                fname+=filewave[ii]
558                                break
559                        endif
560                        ii+=1
561                while(ii<num)
562        elseif (cmpstr(ctrlName,"CurFileBox" )== 0)
563                Wave/T fileWave=$"root:Globals:MainPanel:curWave"
564                PathInfo bt5CurPathName
565                fname = S_Path
566                fname+=filewave[0]
567        endif
568        //Print fname
569        err = LoadBT5File(fname,"RAW")
570        if(err)
571                return(err)
572        endif
573        //if the "Raw Data" Graph exists, do nothing - else draw it
574        //DoWindow/F RawDataWin
575        if(WinType("RawDataWin")!=1)
576                Execute "GraphRawData()"
577        else
578                //just update the textbox
579                //String textStr=StringForRawGraph()
580                //TextBox/W=RawDataWin/C/N=text1/A=RC/X=0.50/Y=-2 textStr
581                //TextBox/W=RawDataWin/C/E=2/A=MT/X=0/Y=0/N=text0 textStr
582                TitleForRawGraph()
583        Endif
584        //bring the panel back to the front
585        DoWindow/F USANS_Panel
586End
587
588// action procedure for the raw data listbox
589// responds to selection or (shift)selection events
590// by acting if the "status" button was pressed
591//(note that the status button is obsolete and not drawn on the USANS_Panel, but
592// I kept the nomenclature)
593//
594Function FileListBoxProc(ctrlName,row,col,event)
595        String ctrlName
596        Variable row,col,event
597       
598        if (cmpstr(ctrlName, "fileLB") == 0)
599                //event == 4 is a selection
600                //event == 5 is a selection + shift key
601                if( (event==4) || (event==5) )
602                        StatusButtonProc(ctrlName)              //act as if status button was pressed
603                        PlotRawButtonProc(ctrlName)                                     //automatically plots the raw data
604                Endif
605                return(0)
606        elseif (cmpstr(ctrlName,"CurFileBox") == 0)
607                //print "Selected current data"
608                if  (event == 4)
609                        StatusButtonProc(ctrlName)
610                        PlotRawButtonProc(ctrlName)
611                endif
612                return(0)
613        endif
614        return(1)
615End
616
617// displays the status of the selected file in the raw data file list box
618// - spits the information out to a second listbox
619// - called automatically as an action when there is a selection in the file listbox
620// not used as a button procedure anymore
621//
622Function StatusButtonProc(ctrlName)
623        String ctrlName
624        String fname=""
625
626        if(cmpstr(ctrlName,"fileLB")==0)
627                //Print "Status Button"
628                //display the (first) selected wave
629                Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
630                Wave sel=$"root:Globals:MainPanel:selFileW"
631                Variable ii=0,num=numpnts(sel)
632               
633                PathInfo bt5PathName
634                fname = S_Path
635                do
636                        if(sel[ii] == 1)
637                                fname+=filewave[ii]
638                                break
639                        endif
640                        ii+=1
641                while(ii<num)
642        elseif(cmpstr(ctrlName,"CurFileBox")==0)
643                Wave/T fileWave=$"root:Globals:MainPanel:curWave"
644                PathInfo bt5CurPathName
645                fname = S_Path
646                fname+=filewave[0]
647        endif           
648        //Print fname
649        ReadBT5Header(fname)
650End
651
652// copies the selected files from the raw file list box to the sam file listbox
653//
654// makes sure that any null items are removed from the wave attached to the listbox
655//
656Function toSamListButtonProc(ctrlName) : ButtonControl
657        String ctrlName
658
659        //Print "toSamList button"
660        Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
661        Wave/T samWave=$"root:Globals:MainPanel:samWave"
662        Wave sel=$"root:Globals:MainPanel:selFileW"
663        //Wave to indicate Current status
664        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
665
666       
667        Variable num=numpnts(sel),ii=0
668        variable lastPt=numpnts(samWave)
669        do
670                if(sel[ii] == 1)
671                        InsertPoints lastPt,1, samWave
672                        samWave[lastPt]=filewave[ii]
673                        InsertPoints lastPt, 1, isCurrent
674                        isCurrent[lastPt] = 0
675                        lastPt +=1
676                endif
677                ii+=1
678        while(ii<num)
679       
680        //clean out any (null) elements
681        num=numpnts(samwave)
682        for(ii=0;ii<num;ii+=1)
683                if(cmpstr(samWave[ii],"") ==0)
684                        DeletePoints ii,1,samWave
685                        DeletePoints ii,1,isCurrent
686                        num -= 1
687                Endif
688        Endfor
689       
690        return(0)
691End
692
693// copies the selected files from the raw file list box to the sam file listbox
694//
695// makes sure that any null items are removed from the wave attached to the listbox
696//
697Function toEmptyListButtonProc(ctrlName) : ButtonControl
698        String ctrlName
699
700        //Print "toEmptyList button"
701        Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
702        Wave/T empWave=$"root:Globals:MainPanel:empWave"
703        Wave sel=$"root:Globals:MainPanel:selFileW"
704        //Wave to indicate Current status
705        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
706
707
708       
709        Variable num=numpnts(sel),ii=0
710        variable lastPt=numpnts(empWave)
711        do
712                if(sel[ii] == 1)
713                        InsertPoints lastPt,1, empWave
714                        empWave[lastPt]=filewave[ii]
715                        InsertPoints lastPt, 1, isCurrent
716                        isCurrent[lastPt] = 0
717                        lastPt +=1
718                endif
719                ii+=1
720        while(ii<num)
721       
722        //clean out any (null) elements
723        num=numpnts(empwave)
724        for(ii=0;ii<num;ii+=1)
725                if(cmpstr(empWave[ii],"") ==0)
726                        DeletePoints ii,1,empWave
727                        DeletePoints ii,1,isCurrent
728                        num -= 1
729                Endif
730        Endfor
731       
732        return(0)
733End
734
735//deletes the selected file from the sam list
736// multiple selections are not allowed
737// the cor_graph is not updated
738//
739Function DelSamButtonProc(ctrlName) : ButtonControl
740        String ctrlName
741       
742        ControlInfo SamLB
743        Variable selRow=V_Value
744        Wave lw=$(S_DataFolder + S_Value)
745        DeletePoints selRow,1,lw       
746        //Clear out current flag AJJ Sept O6
747        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
748        DeletePoints selRow, 1, isCurrent       
749End
750
751//deletes the selected file from the emp list
752// multiple selections are not allowed
753// the cor_graph is not updated
754//
755Function DelEmpButtonProc(ctrlName) : ButtonControl
756        String ctrlName
757       
758        ControlInfo EmpLB
759        Variable selRow=V_Value
760        Wave lw=$(S_DataFolder + S_Value)
761        DeletePoints selRow,1,lw
762        //Clear out current flag AJJ Sept O6
763        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
764        DeletePoints selRow, 1, isCurrent       
765End
766
767//refreshes the file list presented in the raw data file listbox
768//bt5PathName is hard-wired in, will prompt if none exists
769// reads directly from disk
770//
771// EXCLUDES all files that do not match "*.bt5*" (not case sensitive)
772//
773// sorts the list to alphabetical order
774//
775Function RefreshListButtonProc(ctrlName) : ButtonControl
776        String ctrlName
777       
778        SVAR FilterStr = root:Globals:MainPanel:FilterStr
779        String filter
780       
781        //check for path and force user to pick a path
782        do
783                PathInfo bt5PathName
784                if(V_Flag)
785                        break
786                Endif
787                PickBT5Path()
788        while(V_Flag==0)
789       
790        //Get the filter and determine the match string required AJJ Sept06
791        if (stringmatch(FilterStr,"!"))
792                filter = FilterStr+"*.bt5*"
793        else
794                filter = "*.bt5*"
795        endif
796       
797        //get all the files, then trim the list
798        String list=IndexedFile(bt5PathName,-1,"????")
799        String newList="",item=""
800        Variable num=ItemsInList(list,";"),ii
801        for(ii=0;ii<num;ii+=1)
802                item = StringFromList(ii, list  ,";")
803               
804                if( stringmatch(item,filter) )          //ONLY keep files that match the filter + *.bt5 AJJ Sept 06
805                        newlist += item + ";"
806                endif
807                //print "ii=",ii
808        endfor
809        newList = SortList(newList,";",0)       //get them in order
810        num=ItemsInList(newlist,";")
811        Wave/T fileWave = $" root:Globals:MainPanel:fileWave"
812        Wave selFileW = $"root:Globals:MainPanel:selFileW"
813        Redimension/N=(num) fileWave
814        Redimension/N=(num) selFileW
815        fileWave=""
816        selFileW = 0
817        fileWave = StringFromList(p,newlist,";")        //  ! quick and easy assignment of the list
818        Sort filewave,filewave
819       
820End
821
822//clears either the sample or empty scan Lists...
823//Also clears the data folders and the COR_Graph
824//
825// very useful to make sure that the data is really what you think it is on the cor_graph
826//
827Function ClearButtonProc(ctrlName) : ButtonControl
828        String ctrlName
829       
830        SetDataFolder root:Globals:MainPanel
831        strswitch(ctrlName)
832                case "ClearSamButton":
833                        Make/O/T/N=1 samWave
834                        samWave=""
835                        //Clear out current flags AJJ Sept O6
836                        Make/O/N=1 SAMisCurrent,EMPisCurrent
837                        SAMisCurrent = 0
838                        EMPisCurrent = 0
839                        //clear the graph, then the data folders as well
840                        CleanOutGraph("SAM")
841                        CleanOutFolder("SAM")
842                        CleanOutGraph("COR")
843                        CleanOutFolder("COR")
844                        break
845                case "ClearEmpButton":
846                        Make/O/T/N=1 empWave
847                        empWave=""
848                        //Clear out current flags AJJ Sept O6
849                        Make/O/N=1 SAMisCurrent,EMPisCurrent
850                        SAMisCurrent = 0
851                        EMPisCurrent = 0
852                        //clear the graph, then the data folders as well
853                        CleanOutGraph("EMP")
854                        CleanOutFolder("EMP")
855                        CleanOutGraph("COR")
856                        CleanOutFolder("COR")
857                        break
858        endswitch
859        DoWindow/F USANS_Panel          //focus back to MainPanel
860        SetDataFolder root:
861End
862
863//reads header information, to display on main panel only
864// called from the action procedure of the raw data listbox
865//
866// puts the pertinent information in the "statusWave" that is associated
867//with the status listbox (which will automatically update)
868//
869Function ReadBT5Header(fname)
870        String fname
871       
872        Variable err=0,refNum
873        Wave/T statusWave=$"root:Globals:MainPanel:statusWave"
874       
875        Open/R refNum as fname          //READ-ONLY.......if fname is "", a dialog will be presented
876        if(refnum==0)
877                return(1)               //user cancelled
878        endif
879        //read in the ASCII data line-by-line
880        Variable numLinesLoaded = 0,firstchar
881        Variable v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,ii,valuesRead
882        String buffer ="",s1,s2,s3,s4,s5,s6,s7,s8,s9,s10
883       
884        //parse the first line
885        FReadLine refnum,buffer
886        sscanf buffer, "%s%s%s%s%s%s%g%g%s%g%s",s1,s2,s3,s4,s5,s6,v1,v2,s7,v3,s8
887        statusWave[0] = "FILE: "+s1
888        statusWave[1] = "DATE: "+s2+" "+s3+" "+s4+" "+s5
889       
890        //v1 is the time per point (sec)
891        //v2  is the monitor prefactor. Let's multiply the time by the prefactor. AJJ 5 March 07
892        statusWave[2] = "TIME/PT: "+num2istr(v1*v2)+" sec"
893       
894        //skip the next line
895        FReadLine refnum,buffer
896        //the next line is the title, use it all
897        FReadLine refnum,buffer
898        statusWave[3] = "TITLE: "+ buffer
899       
900        //skip the next 3 lines
901        For(ii=0;ii<3;ii+=1)
902                FReadLine refnum,buffer
903        EndFor
904       
905        //parse the angular range from the next line
906        FReadLine refnum,buffer
907        sscanf buffer,"%g%g%g%g",v1,v2,v3,v4
908        statusWave[4] = "RANGE: "+num2str(v2)+" to "+num2str(v4)+" step "+num2str(v3)
909       
910        Close refNum            // Close the file, read-only, so don't need to move to EOF first
911        return err                      // Zero signifies no error.     
912End
913
914// given a string that is the wavenote of the just-loaded raw data file
915// pick out the file and time list items (and values)
916//and return a string that is to be used for the textbox in the graph of raw data
917//
918Function TitleForRawGraph()
919
920        WAVE detCts=$"root:RAW:detCts"
921        WAVE monCts = $"root:RAW:monCts"
922        String str=note(detCts)
923       
924        String retStr="\\JC"
925        retStr += StringByKey("FILE",str,":",";")+"\r"
926        retStr += "Count Time: "+StringByKey("TIMEPT",str,":",";")
927        retStr += " \tMonitor Rate: "+num2str(mean(monCts)/NumberByKey("TIMEPT",str,":",";"))+"\r"
928        retStr += "\\s(DetCts) DetCts \\s(TransCts) TransCts \\s(MonCts) MonCts"
929       
930        TextBox/W=RawDataWin/C/E=2/A=MT/X=5/Y=0/N=text0 retStr
931End
932
933
934//concatenates datasets (full names are passed in as a string)
935//tacks w2 onto the end of w1 (so keep w1)
936//
937// copied from a wavemetrics procedure (concatenatewaves?)
938Function ConcatenateData(w1, w2)
939        String w1, w2
940       
941        Variable numPoints1, numPoints2
942
943        if (Exists(w1) == 0)
944                Duplicate $w2, $w1
945        else
946                String wInfo=WaveInfo($w2, 0)
947                numPoints1 = numpnts($w1)
948                numPoints2 = numpnts($w2)
949                Redimension/N=(numPoints1 + numPoints2) $w1
950                Wave/D ww1=$w1
951                Wave/D ww2=$w2
952                ww1[numPoints1, ] = ww2[p-numPoints1]
953        endif
954End
955
956//takes the given inputs, subtracts EMP and BKG from the SAM data
957//the user must supply the correct sample thickness, BKGLevel, and EMPLevel for extrapolation
958Function DoCorrectData()
959       
960        //constants
961//      NVAR  thetaH = root:Globals:MainPanel:gTheta_H                  //Darwin FWHM
962//      NVAR  thetaV = root:Globals:MainPanel:gTheta_V                  //Vertical divergence
963        NVAR dOmega =  root:Globals:MainPanel:gDomega                   //Solid angle of detector
964        NVAR defaultMCR = root:Globals:MainPanel:gDefaultMCR
965        //waves
966        Wave iqSAM = $"root:SAM:DetCts"
967        Wave errSAM = $"root:SAM:ErrDetCts"
968        Wave qvalSAM = $"root:SAM:Qvals"
969        Wave iqEMP = $"root:EMP:DetCts"
970        Wave errEMP = $"root:EMP:ErrDetCts"
971        Wave qvalEMP = $"root:EMP:Qvals"
972        //BKG,EMP levels,trans,thick
973        NVAR bkgLevel = root:Globals:MainPanel:gBkgCts
974        NVAR empLevel = root:Globals:MainPanel:gEmpCts
975        NVAR Trock = root:Globals:MainPanel:gTransRock
976        NVAR Twide = root:Globals:MainPanel:gTransWide
977        NVAR thick = root:Globals:MainPanel:gThick
978        //New waves in COR folder, same length as SAM data
979        Duplicate/O iqSAM,$"root:COR:DetCts"
980        Duplicate/O errSAM,$"root:COR:ErrDetCts"
981        Duplicate/O qvalSAM,$"root:COR:Qvals"
982        Wave iqCOR = $"root:COR:DetCts"
983        Wave qvalCOR = $"root:COR:Qvals"
984        Wave errCOR = $"root:COR:ErrDetCts"
985       
986        //correction done here
987        //q-values of EMP must be interpolated to match SAM data
988        //use the extrapolated value of EMP beyind its measured range
989        Variable num=numpnts(iqSAM),ii,scale,tempI,temperr,maxq,wq
990        maxq = qvalEMP[(numpnts(qvalEMP)-1)]            //maximum measure q-value for the empty
991       
992        for(ii=0;ii<num;ii+=1)
993                wq = qvalSAM[ii]        //q-point of the sample
994                if(wq<maxq)
995                        tempI = interp(wq,qvalEMP,iqEMP)
996                        temperr = interp(wq,qvalEMP,errEMP)
997                else
998                        tempI = empLevel
999                        //temperr = sqrt(empLevel)
1000                        temperr = 0             //JGB 5/31/01
1001                endif
1002                iqCOR[ii] = iqSAM[ii] - Trock*tempI - (1-Trock)*bkglevel
1003                errCOR[ii] = sqrt(errSAM[ii]^2 + Trock^2*temperr^2)             //Trock^2; JGB 5/31/01
1004        endfor
1005       
1006        String str=note(iqEMP)
1007        Variable pkHtEMP=NumberByKey("PEAKVAL", str,":",";")
1008        //absolute scaling factor
1009        scale = 1/(Twide*thick*dOmega*pkHtEMP)
1010        iqCOR *= scale
1011        errCOR *= scale
1012       
1013        //copy to Graph directory to plot
1014        Duplicate/O $("root:COR:Qvals"),$("root:Graph:Qvals_COR")
1015        Duplicate/O $("root:COR:DetCts"),$("root:Graph:DetCts_COR")
1016        Duplicate/O $("root:COR:ErrDetCts"),$("root:Graph:ErrDetCts_COR")
1017       
1018        //now plot the data (or just bring the graph to the front)
1019        DoCORGraph()
1020        return(0)
1021End
1022
1023//cleans out the specified data folder (type)
1024// and clears out the same-named data from the Graph folder
1025// kills what is not in use
1026//
1027Function CleanOutFolder(type)
1028        String type
1029       
1030        SetDataFolder $("root:"+type)
1031        Killwaves/Z DetCts,Qvals,ErrDetCts,Angle,MonCts,TransCts
1032       
1033        SetDataFolder root:Graph
1034        KillWaves/Z $("DetCts_"+type),$("ErrDetCts_"+type),$("Qvals_"+type)
1035       
1036        SetDataFolder root:
1037End
1038
1039// removes the selected datatype from the COR_Graph
1040//                     
1041Function CleanOutGraph(type)
1042        String type
1043       
1044        DoWindow/F COR_Graph
1045        if(V_flag)
1046                RemoveFromGraph/W=COR_Graph/Z $("DetCts_"+type)
1047        endif
1048End
1049
1050//Edits by AJJ, September 2006
1051//Add functions to get data from Current Folder
1052
1053Function RefreshCurrentButtonProc(ctrlName) : ButtonControl
1054        String ctrlName
1055       
1056        //Prod the web update page
1057        //This is a horrible kludge that doesn't really work as the
1058        //webscript does not update the current run as of Sept 26 2006
1059        //Will get Nick M to look into it
1060        BrowseURL/Z "http://www-i.ncnr.nist.gov/icpdata/recent.php?action=1&instr=bt5"
1061       
1062        Print "Waiting 20s for update..."
1063        Sleep/S 20
1064        Print "Waited 20s, new file should be there."
1065       
1066        //check for path and force user to pick a path
1067        //assume that if bt5PathName has been assigned, so has bt5CurPathName
1068        do
1069                PathInfo bt5PathName
1070                if(V_Flag)
1071                        break
1072                Endif
1073                PickBT5Path()
1074        while(V_Flag==0)
1075       
1076        PathInfo bt5CurPathName
1077        if(V_flag==0)
1078                NewPath/O/M="Select Current Data" bt5CurPathName, getCurrentPath(S_Path)
1079        endif
1080               
1081        //get all the files, then trim the list
1082        String list=IndexedFile(bt5CurPathName,-1,"????")
1083        String newList="",item=""
1084        Variable num=ItemsInList(list,";"),ii
1085        for(ii=0;ii<num;ii+=1)
1086                item = StringFromList(ii, list  ,";")
1087                if( stringmatch(item,"*.bt5*") )                //ONLY keep files with ".bt5" in the name (NOT case-sensitive)
1088                        newlist += item + ";"
1089                endif
1090                //print "ii=",ii
1091        endfor
1092        newList = SortList(newList,";",0)       //get them in order
1093        num=ItemsInList(newlist,";")
1094        Wave/T curWave = $" root:Globals:MainPanel:curWave"
1095        Redimension/N=(num) curWave
1096        curWave=""
1097        curWave = StringFromList(p,newlist,";") //  ! quick and easy assignment of the list
1098        Sort curwave,curwave
1099       
1100End
1101
1102//Reduced version of toSamListButtonProc for putting current data into Sample data
1103Function CurtoSamListButtonProc(ctrlName) : ButtonControl
1104        String ctrlName
1105
1106        Wave/T curWave=$"root:Globals:MainPanel:curWave"
1107        Wave/T samWave=$"root:Globals:MainPanel:samWave"
1108        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
1109       
1110        Variable num, ii = 0
1111        variable lastPt=numpnts(samWave)
1112       
1113        InsertPoints lastPt,1, samWave
1114        samWave[lastPt]=curwave[ii]
1115        InsertPoints lastPt, 1, isCurrent
1116        isCurrent[lastPt] = 1
1117       
1118        //clean out any (null) elements
1119        num = numpnts(samwave)
1120        for(ii=0;ii<num;ii+=1)
1121                if(cmpstr(samWave[ii],"") ==0)
1122                        DeletePoints ii,1,samWave
1123                        DeletePoints ii,1,isCurrent
1124                        num -= 1
1125                Endif
1126        Endfor
1127       
1128        return(0)
1129End
1130
1131//Reduced version of toEmptyListButtonProc for putting current data into Empty data
1132Function CurtoEmptyListButtonProc(ctrlName) : ButtonControl
1133        String ctrlName
1134
1135        Wave/T curWave=$"root:Globals:MainPanel:curWave"
1136        Wave/T empWave=$"root:Globals:MainPanel:empWave"
1137        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
1138               
1139        Variable num, ii=0
1140        variable lastPt=numpnts(empWave)
1141
1142        InsertPoints lastPt,1, empWave
1143        empWave[lastPt]=curwave[ii]
1144        InsertPoints lastPt, 1, isCurrent
1145        isCurrent[lastPt] = 1
1146
1147       
1148        //clean out any (null) elements
1149        num=numpnts(empwave)
1150        for(ii=0;ii<num;ii+=1)
1151                if(cmpstr(empWave[ii],"") ==0)
1152                        DeletePoints ii,1,empWave
1153                        DeletePoints ii,1,isCurrent
1154                        num -= 1
1155                Endif
1156        Endfor
1157       
1158       
1159        return(0)
1160End
1161
1162Function UseCurrentDataProc(ctrlName,checked) : CheckBoxControl
1163        String ctrlName
1164        Variable checked
1165       
1166        NVAR isChecked = root:Globals:MainPanel:gUseCurrentData
1167       
1168        if (checked == 1)
1169                DoAlert 1, "Enabling Current Data requires access to the NCNR Network.\rDo you wish to continue?"
1170                if(V_flag == 1)
1171                        ModifyControl/Z CurFileBox, disable=0
1172                        ModifyControl/Z AddCurToSAM, disable=0
1173                        ModifyControl/Z AddCurToEMP, disable=0
1174                        ModifyControl/Z RefreshCurrent,disable=0
1175                        isChecked = 1
1176                endif
1177        else
1178                ModifyControl/Z CurFileBox, disable=1
1179                ModifyControl/Z AddCurToSAM, disable=2
1180                ModifyControl/Z AddCurToEMP, disable=2
1181                ModifyControl/Z RefreshCurrent,disable=2       
1182                isChecked = 0
1183        endif
1184
1185End
1186
1187//Function to get path for Current file
1188Function/S getCurrentPath(inPath)
1189        String inPath
1190       
1191        Variable pos=0,mpos = 0
1192        Variable i = 0,j = 0
1193        // The saga continues...
1194        // Originally used ParseFilePath - not in Igor 4
1195        // Switched to strsearch, but useful searching from end of string not in Igor 4
1196        // Now have ugly loops going through the string, but should work.
1197
1198        for( i = 0;i<4; i+=1)   
1199                do
1200                        pos = strsearch(inPath,":",j)
1201                        if (pos != -1)
1202                                mpos = pos
1203                        endif
1204                        j = pos+1
1205                while (pos !=-1)
1206               
1207                inPath = inPath[0,mpos -1]
1208                pos = 0
1209                mpos = 0
1210                j = 0
1211        endfor
1212       
1213        inPath = inPath + ":current:"
1214
1215        return inPath
1216       
1217End
1218
1219//
1220Function U_OpenTracTicketPage(ctrlName)
1221        String ctrlName
1222        DoAlert 1,"Your web browser will open to a page where you can submit your bug report or feature request. OK?"
1223        if(V_flag==1)
1224                BrowseURL "http://danse.chem.utk.edu/trac/newticket"
1225        endif
1226End
1227
1228
Note: See TracBrowser for help on using the repository browser.