source: sans/USANSReduction/trunk/Put in User Procedures Folder/USANS Procedures v2.21/Main_USANS.ipf @ 265

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

Major structural changes, hopefully correct, to prepare for v2.21 release (not tagged yet)

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