source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/PlotUtilsMacro.ipf @ 153

Last change on this file since 153 was 138, checked in by ajj, 15 years ago

Adding matrix method of calculating slit smearing for USANS Data.

-- Notes --

  • Calculating the matrix takes about .5 to 1 second on my Macbook Pro (faster than I remember!)
  • Choice of extrapolation slope as a bigger effect than I remember.
  • Nothing done with Smearing functions to make them use this.
File size: 20.5 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=3.00
3#pragma IgorVersion=6.0
4
5// This is to be used with the Analysis packages ONLY
6// there are a number of utility procedures here for loading
7// data and generating valid lists of data files that are
8// directly copied from the Reduction package
9// -- There WILL be name conflicts if you mix the two...
10//
11// 16 DEC 05 SRK
12// prepended function names with A_ to tag them for the
13// "A"nalysis parckage, though nearly all are duplicate procedures
14// so there will be no overlap with the reduction package
15//
16//
17// these extra procedures are used by:
18// Linearized fits (duplicated in Reduction - will need to handle gently)
19// Invariant (no overlap with reduction)
20//
21// SRK MAR 2005
22
23// loads a 1-d (ascii) datafile and plots the data
24// will overwrite existing data if user is OK with this
25// - multiple datasets can be automatically plotted on the same graph
26//
27//substantially easier to write this as a Proc rather than a function...
28
29//
30Proc A_LoadOneDData()
31        A_LoadOneDDataWithName("",1)            //will prompt for file and plot data
32End
33
34// load the data specified by fileStr (a full path:name)
35// and plots if doPlot==1
36// if fileStr is null, a dialog is presented to select the file
37//
38// 3 cases (if)
39// - 3 columns = QIS, no resolution
40// - 6 columns = QSIG, SANS w/resolution
41// - 5 columns = old-style desmeared USANS data (from VAX)
42//
43// This loader replaces the A_LoadOneDData() which was almost completely duplicated code
44//
45//new version, 19JUN07 that loads each data set into a separate data folder
46// the data folder is given the "base name" of the data file as it's loaded
47//
48Proc A_LoadOneDDataWithName(fileStr,doPlot)
49        String fileStr
50        Variable doPlot
51       
52        Variable rr,gg,bb
53        SetDataFolder root:             //build sub-folders for each data set under root
54       
55        //Load the waves, using default waveX names
56        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
57        LoadWave/G/D/A/Q fileStr
58        String fileName = S_fileName
59        Variable numCols = V_flag
60       
61        if(numCols==3)          //simple 3-column data with no resolution information
62                String w0,w1,w2,n0,n1,n2
63               
64                // put the names of the three loaded waves into local names
65                n0 = StringFromList(0, S_waveNames ,";" )
66                n1 = StringFromList(1, S_waveNames ,";" )
67                n2 = StringFromList(2, S_waveNames ,";" )
68               
69                //remove the semicolon AND period from files from the VAX
70                w0 = CleanupName((S_fileName + "_q"),0)
71                w1 = CleanupName((S_fileName + "_i"),0)
72                w2 = CleanupName((S_fileName + "_s"),0)
73               
74                String baseStr=w1[0,strlen(w1)-3]
75                if(DataFolderExists("root:"+baseStr))
76                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
77                                if(V_flag==2)   //user selected No, don't load the data
78                                        SetDataFolder root:
79                                        KillWaves $n0,$n1,$n2           // kill the default waveX that were loaded
80                                        //if(DataFolderExists("root:myGlobals"))
81                                        //      String/G root:myGlobals:gLastFileName = filename
82                                        //endif
83                                        return          //quits the macro
84                                endif
85                                SetDataFolder $("root:"+baseStr)
86                else
87                        NewDataFolder/S $("root:"+baseStr)
88                endif
89               
90                ////overwrite the existing data, if it exists
91                Duplicate/O $("root:"+n0), $w0
92                Duplicate/O $("root:"+n1), $w1
93                Duplicate/O $("root:"+n2), $w2
94
95                // no resolution matrix to make
96
97                SetScale d,0,0,"1/A",$w0
98                SetScale d,0,0,"1/cm",$w1
99               
100        endif           //3-col data
101       
102        if(numCols == 6)                //6-column SANS or USANS data that has resolution information
103                String w0,w1,w2,n0,n1,n2
104                String w3,w4,w5,n3,n4,n5                        //3 extra waves to load
105               
106                // put the names of the (default named) loaded waves into local names
107                n0 = StringFromList(0, S_waveNames ,";" )
108                n1 = StringFromList(1, S_waveNames ,";" )
109                n2 = StringFromList(2, S_waveNames ,";" )
110                n3 = StringFromList(3, S_waveNames ,";" )
111                n4 = StringFromList(4, S_waveNames ,";" )
112                n5 = StringFromList(5, S_waveNames ,";" )
113               
114                //remove the semicolon AND period from files from the VAX
115                w0 = CleanupName((S_fileName + "_q"),0)
116                w1 = CleanupName((S_fileName + "_i"),0)
117                w2 = CleanupName((S_fileName + "_s"),0)
118                w3 = CleanupName((S_fileName + "sq"),0)
119                w4 = CleanupName((S_fileName + "qb"),0)
120                w5 = CleanupName((S_fileName + "fs"),0)
121               
122                String baseStr=w1[0,strlen(w1)-3]
123                if(DataFolderExists("root:"+baseStr))
124                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
125                                if(V_flag==2)   //user selected No, don't load the data
126                                        SetDataFolder root:
127                                        KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded
128                                        //if(DataFolderExists("root:myGlobals"))
129                                        //      String/G root:myGlobals:gLastFileName = filename
130                                        //endif         //set the last file loaded to the one NOT loaded
131                                        return          //quits the macro
132                                endif
133                                SetDataFolder $("root:"+baseStr)
134                else
135                        NewDataFolder/S $("root:"+baseStr)
136                endif
137
138////overwrite the existing data, if it exists
139                Duplicate/O $("root:"+n0), $w0
140                Duplicate/O $("root:"+n1), $w1
141                Duplicate/O $("root:"+n2), $w2
142                Duplicate/O $("root:"+n3), $w3
143                Duplicate/O $("root:"+n4), $w4
144                Duplicate/O $("root:"+n5), $w5
145
146                // need to switch based on SANS/USANS
147                if (isSANSResolution($w3[0]))           //checks to see if the first point of the wave is <0]
148                        // make a resolution matrix for SANS data
149                        Variable np=numpnts($w0)
150                        Make/O/N=(np,4) $(baseStr+"_res")
151                       
152                        $(baseStr+"_res")[][0] = $w3[p]         //sigQ
153                        $(baseStr+"_res")[][1] = $w4[p]         //qBar
154                        $(baseStr+"_res")[][2] = $w5[p]         //fShad
155                        $(baseStr+"_res")[][3] = $w0[p]         //Qvalues
156                else
157                        //the data is USANS data
158                        // marix calculation here, but for now, just copy the waves
159                        //$(baseStr+"_res")[][0] = $w3[p]               //sigQ
160                        //$(baseStr+"_res")[][1] = $w4[p]               //qBar
161                        //$(baseStr+"_res")[][2] = $w5[p]               //fShad
162                        //$(baseStr+"_res")[][3] = $w0[p]               //Qvalues
163                       
164                        USANS_CalcWeights(baseStr,-$w3[0])
165                       
166                endif
167                Killwaves/Z $w3,$w4,$w5                 //get rid of the resolution waves that are in the matrix
168
169                SetScale d,0,0,"1/A",$w0
170                SetScale d,0,0,"1/cm",$w1
171       
172        endif   //6-col data
173
174        if(numCols==5)          //this is the "old-style" VAX desmeared data format
175                String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4
176                Variable rr,gg,bb
177               
178                // put the names of the three loaded waves into local names
179                n0 = StringFromList(0, S_waveNames ,";" )
180                n1 = StringFromList(1, S_waveNames ,";" )
181                n2 = StringFromList(2, S_waveNames ,";" )
182                n3 = StringFromList(3, S_waveNames ,";" )
183                n4 = StringFromList(4, S_waveNames ,";" )
184               
185               
186                //remove the semicolon AND period from files from the VAX
187                w0 = CleanupName((S_fileName+"_q"),0)
188                w1 = CleanupName((S_fileName+"_i"),0)
189                w2 = CleanupName((S_fileName+"_s"),0)
190                w3 = CleanupName((S_fileName+"_ism"),0)
191                w4 = CleanupName((S_fileName+"_fit_ism"),0)
192               
193                String baseStr=w1[0,strlen(w1)-3]
194                if(DataFolderExists("root:"+baseStr))
195                                DoAlert 1,"The file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
196                                if(V_flag==2)   //user selected No, don't load the data
197                                        KillWaves $n0,$n1,$n2,$n3,$n4,$n5               // kill the default waveX that were loaded
198                                        //if(DataFolderExists("root:myGlobals"))
199                                        //      String/G root:myGlobals:gLastFileName = filename
200                                        //endif         //set the last file loaded to the one NOT loaded
201                                        return          //quits the macro
202                                endif
203                                SetDataFolder $("root:"+baseStr)
204                else
205                        NewDataFolder/S $("root:"+baseStr)
206                endif
207               
208                ////overwrite the existing data, if it exists   
209                Duplicate/O $("root:"+n0), $w0
210                Duplicate/O $("root:"+n1), $w1
211                Duplicate/O $("root:"+n2), $w2
212                Duplicate/O $("root:"+n3), $w3
213                Duplicate/O $("root:"+n4), $w4
214               
215                // no resolution matrix
216        endif           //5-col data
217       
218        //////
219        if(DataFolderExists("root:myGlobals"))
220                String/G root:myGlobals:gLastFileName = filename
221        endif
222       
223        //plot if desired
224        if(doPlot)
225                // assign colors randomly
226                rr = abs(trunc(enoise(65535)))
227                gg = abs(trunc(enoise(65535)))
228                bb = abs(trunc(enoise(65535)))
229               
230                // if target window is a graph, and user wants to append, do so
231           DoWindow/B Plot_Manager
232                if(WinType("") == 1)
233                        DoAlert 1,"Do you want to append this data to the current graph?"
234                        if(V_Flag == 1)
235                                AppendToGraph $w1 vs $w0
236                                ModifyGraph mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1) =(rr,gg,bb)
237                                ErrorBars $w1 Y,wave=($w2,$w2)
238                        else
239                        //new graph
240                                Display $w1 vs $w0
241                                ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb)
242                                ModifyGraph grid=1,mirror=2,standoff=0
243                                ErrorBars $w1 Y,wave=($w2,$w2)
244                                Legend
245                        endif
246                else
247                // graph window was not target, make new one
248                        Display $w1 vs $w0
249                        ModifyGraph log=1,mode($w1)=3,marker($w1)=19,msize($w1)=2,rgb($w1)=(rr,gg,bb)
250                        ModifyGraph grid=1,mirror=2,standoff=0
251                        ErrorBars $w1 Y,wave=($w2,$w2)
252                        Legend
253                endif
254        endif
255               
256        //go back to the root folder and clean up before leaving
257        SetDataFolder root:
258        KillWaves/Z $n0,$n1,$n2,$n3,$n4,$n5
259End
260
261
262//procedure for loading NSE data in the format (4-columns)
263// qvals - time - I(q,t) - dI(q,t)
264//
265//
266// this does NOT load the data into separate folders...
267//
268Proc A_LoadNSEData()
269        A_LoadNSEDataWithName("",1)
270End
271
272Proc A_LoadNSEDataWithName(fileStr,doPlot)
273
274        //Load the waves, using default waveX names
275        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
276        LoadWave/G/D/A  fileStr
277        String filename = S_fileName
278       
279        String w0,w1,w2,n0,n1,n2,wt,w3,n3
280        Variable rr,gg,bb
281       
282        // put the names of the three loaded waves into local names
283        n0 = StringFromList(0, S_waveNames ,";" )
284        n1 = StringFromList(1, S_waveNames ,";" )
285        n2 = StringFromList(2, S_waveNames ,";" )
286        n3 = StringFromList(3, S_waveNames ,";" )
287       
288       
289        //remove the semicolon AND period from files from the VAX
290        w0 = CleanupName(("qvals_"+S_fileName),0)
291        w1 = CleanupName(("time_"+S_fileName),0)
292        w2 = CleanupName(("iqt_"+S_fileName),0)
293        w3 = CleanupName(("iqterr_"+S_fileName),0)
294       
295        if(exists(w0) !=0)
296                DoAlert 0,"This file has already been loaded. Use Append to Graph..."
297                KillWaves $n0,$n1,$n2           // kill the default waveX that were loaded
298                return
299        endif
300       
301        // Rename to give nice names
302        Rename $n0, $w0
303        Rename $n1, $w1
304        Rename $n2, $w2
305        Rename $n3, $w3
306               
307        if(doPlot)
308                // assign colors randomly
309                rr = abs(trunc(enoise(65535)))
310                gg = abs(trunc(enoise(65535)))
311                bb = abs(trunc(enoise(65535)))
312               
313                // if target window is a graph, and user wants to append, do so
314                if(WinType("") == 1)
315                        DoAlert 1,"Do you want to append this data to the current graph?"
316                        if(V_Flag == 1)
317                                AppendToGraph $w2 vs $w1
318                                ModifyGraph mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2) =(rr,gg,bb),grid=1,mirror=2,tickUnit=1
319                                ErrorBars $w2 Y,wave=($w3,$w3)
320                        else
321                        //new graph
322                                Display $w2 vs $w1
323                                ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1
324                                ErrorBars $w2 Y,wave=($w3,$w3)
325                                Legend
326                        endif
327                else
328                // graph window was not target, make new one
329                        Display $w2 vs $w1
330                        ModifyGraph standoff=0,mode($w2)=3,marker($w2)=29,msize($w2)=2,rgb($w2)=(rr,gg,bb),grid=1,mirror=2,tickUnit=1
331                        ErrorBars $w2 Y,wave=($w3,$w3)
332                        Legend
333                endif
334        endif //doPlot         
335
336End
337
338//procedure for loading desmeared USANS data in the format (5-columns)
339// qvals - I(q) - sig I - Ism(q) - fitted Ism(q)
340//no weighting wave is created (not needed in IGOR 4)
341//
342// not really ever used...
343//
344Proc A_LoadUSANSData()
345
346        //Load the waves, using default waveX names
347        //if no path or file is specified for LoadWave, the default Mac open dialog will appear
348        LoadWave/G/D/A
349   String filename = S_fileName
350       
351        String w0,w1,w2,n0,n1,n2,w3,n3,w4,n4
352        Variable rr,gg,bb
353       
354        // put the names of the three loaded waves into local names
355        n0 = StringFromList(0, S_waveNames ,";" )
356        n1 = StringFromList(1, S_waveNames ,";" )
357        n2 = StringFromList(2, S_waveNames ,";" )
358        n3 = StringFromList(3, S_waveNames ,";" )
359        n4 = StringFromList(4, S_waveNames ,";" )
360       
361       
362        //remove the semicolon AND period from files from the VAX
363        w0 = CleanupName((S_fileName+"_q"),0)
364        w1 = CleanupName((S_fileName+"_i"),0)
365        w2 = CleanupName((S_fileName+"_s"),0)
366        w3 = CleanupName((S_fileName+"_ism"),0)
367        w4 = CleanupName((S_fileName+"_fit_ism"),0)
368       
369        if(exists(w0) !=0)              //the wave already exists
370                DoAlert 1,"This file "+S_filename+" has already been loaded. Do you want to load the new data file, overwriting the data in memory?"
371                if(V_flag==2)   //user selected No
372                        KillWaves $n0,$n1,$n2,$n3,$n4           // kill the default waveX that were loaded
373                        if(DataFolderExists("root:myGlobals"))
374                                String/G root:myGlobals:gLastFileName = filename
375                        endif           //set the last file loaded to the one NOT loaded
376                        return          //quits the macro
377                endif
378        endif
379       
380        ////overwrite the existing data, if it exists
381        Duplicate/O $n0, $w0
382        Duplicate/O $n1, $w1
383        Duplicate/O $n2, $w2
384        Duplicate/O $n3, $w3
385        Duplicate/O $n4, $w4
386        KillWaves $n0,$n1,$n2,$n3,$n4
387       
388        if(DataFolderExists("root:myGlobals"))
389                String/G root:myGlobals:gLastFileName = filename
390        endif
391               
392        // assign colors randomly
393        rr = abs(trunc(enoise(65535)))
394        gg = abs(trunc(enoise(65535)))
395        bb = abs(trunc(enoise(65535)))
396       
397                // if target window is a graph, and user wants to append, do so
398        if(WinType("") == 1)
399                DoAlert 1,"Do you want to append this data to the current graph?"
400                if(V_Flag == 1)
401                        AppendToGraph $w1 vs $w0
402                        ModifyGraph mode=3,marker=29,msize=2,rgb ($w1) =(rr,gg,bb),tickUnit=1,grid=1,mirror=2
403                        ErrorBars $w1 Y,wave=($w2,$w2)
404                else
405                //new graph
406                        Display $w1 vs $w0
407                        ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
408                        ErrorBars $w1 Y,wave=($w2,$w2)
409                        Legend
410                endif
411        else
412        // graph window was not target, make new one
413                Display $w1 vs $w0
414                ModifyGraph log=1,mode=3,marker=29,msize=2,rgb=(rr,gg,bb),tickUnit=1,grid=1,mirror=2
415                ErrorBars $w1 Y,wave=($w2,$w2)
416                Legend
417        endif
418               
419End
420
421
422//// Extra "Utility Procedures"
423// to pick path, get a list of data files, and make sure that a valid filename
424// is passed to LoadOneDDataWithName()
425//
426
427//prompts user to choose the local folder that contains the SANS Data
428//only one folder can be used, and its path is catPathName (and is a NAME, not a string)
429//this will overwrite the path selection
430//returns 1 if no path selected as error condition
431Function A_PickPath()
432       
433        //set the global string to the selected pathname
434        NewPath/O/M="pick the SANS data folder" catPathName
435        PathInfo/S catPathName
436        String dum = S_path
437        String alertStr = ""
438        alertStr = "You must set the path to Charlotte through a Mapped Network Drive, not through the Network Neighborhood"
439        //alertStr += "  Please see the manual for details."
440        if (V_flag == 0)
441                //path does not exist - no folder selected
442                String/G root:myGlobals:gCatPathStr = "no folder selected"
443                return(1)
444        else
445                //set the global to the path (as a string)
446                // need 4 \ since it is the escape character
447                if(cmpstr("\\\\",dum[0,1])==0)  //Windoze user going through network neighborhood
448                        DoAlert 0,alertStr
449                        KillPath catPathName
450                        return(1)
451                endif
452                String/G root:myGlobals:gCatPathStr = dum
453                return(0)               //no error
454        endif
455End
456
457//Function attempts to find valid filename from partial name that has been stripped of
458//the VAX version number. The partial name is tried first
459//*** the PATH is hard-wired to catPathName (which is assumed to exist)
460//version numers up to ;10 are tried
461//only the "name;vers" is returned. the path is not prepended, hence the return string
462//is not a complete specification of the file
463//
464// added 11/99 - uppercase and lowercase versions of the file are tried, if necessary
465// since from marquee, the filename field (textread[0]) must be used, and can be a mix of
466// upper/lowercase letters, while the filename on the server (should) be all caps
467// now makes repeated calls to ValidFileString()
468//
469Function/S A_FindValidFilename(partialName)
470        String PartialName
471       
472        String retStr=""
473       
474        //try name with no changes - to allow for ABS files that have spaces in the names 12APR04
475        retStr = A_ValidFileString(partialName)
476        if(cmpstr(retStr,"") !=0)
477                //non-null return
478                return(retStr)
479        Endif
480       
481        //if the partial name is derived from the file header, there can be spaces at the beginning
482        //or in the middle of the filename - depending on the prefix and initials used
483        //
484        //remove any leading spaces from the name before starting
485        partialName = A_RemoveAllSpaces(partialName)
486       
487        //try name with no spaces
488        retStr = A_ValidFileString(partialName)
489        if(cmpstr(retStr,"") !=0)
490                //non-null return
491                return(retStr)
492        Endif
493       
494        //try all UPPERCASE
495        partialName = UpperStr(partialName)
496        retStr = A_ValidFileString(partialName)
497        if(cmpstr(retStr,"") !=0)
498                //non-null return
499                return(retStr)
500        Endif
501       
502        //try all lowercase (ret null if failure)
503        partialName = LowerStr(partialName)
504        retStr = A_ValidFileString(partialName)
505        if(cmpstr(retStr,"") !=0)
506                //non-null return
507                return(retStr)
508        else
509                return(retStr)
510        Endif
511End
512
513//function to test a binary file to see if it is a RAW binary SANS file
514//first checks the total bytes in the file (which for raw data is 33316 bytes)
515//**note that the "DIV" file will also show up as a raw file by the run field
516//should be listed in CAT/SHORT and in patch windows
517//
518//Function then checks the file fname (full path:file) for "RAW" run.type field
519//if not found, the data is not raw data and zero is returned
520Function A_CheckIfRawData(fname)
521        String fname
522       
523        Variable refnum,totalBytes
524        String testStr=""
525       
526        Open/R/T="????TEXT" refNum as fname
527        //get the total number of bytes in the file, to avoid moving past EOF
528        FStatus refNum
529        totalBytes = V_logEOF
530        //Print totalBytes
531        if(totalBytes!=33316)
532                //can't possibly be a raw data file
533                Close refnum
534                return(0)               //not a raw SANS file
535        Endif
536        FSetPos refNum,75
537        FReadLine/N=3 refNum,testStr
538        Close refNum
539       
540        if(cmpstr(testStr,"RAW")==0)
541                //true, is raw data file
542                Return(1)
543        else
544                //some other file
545                Return(0)
546        Endif
547End
548
549//list (input) is a list, typically returned from IndexedFile()
550//which is semicolon-delimited, and may contain filesnames from the VAX
551//that contain version numbers, where the version number appears as a separate list item
552//(and also as a non-existent file)
553//these numbers must be purged from the list, especially for display in a popup
554//or list processing of filenames
555//the function returns the list, cleaned of version numbers (up to 11)
556//raw data files will typically never have a version number other than 1.
557Function/S A_RemoveVersNumsFromList(list)
558        String list
559       
560        //get rid of version numbers first (up to 11)
561        Variable ii,num
562        String item
563        num = ItemsInList(list,";")
564        ii=1
565        do
566                item = num2str(ii)
567                list = RemoveFromList(item, list ,";" )
568                ii+=1
569        while(ii<12)
570       
571        return (list)
572End
573
574//Function attempts to find valid filename from partial name that has been stripped of
575//the VAX version number. The partial name is tried first
576//*** the PATH is hard-wired to catPathName (which is assumed to exist)
577//version numers up to ;10 are tried
578//only the "name;vers" is returned. the path is not prepended, hence the return string
579//is not a complete specification of the file
580//
581Function/S A_ValidFileString(partialName)
582        String partialName
583       
584        String tempName = "",msg=""
585        Variable ii,refnum
586       
587        ii=0
588        do
589                if(ii==0)
590                        //first pass, try the partialName
591                        tempName = partialName
592                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName     //Does open file (/Z flag)
593                        if(V_flag == 0)
594                                //file exists
595                                Close refnum            //YES needed,
596                                break
597                        endif
598                else
599                        tempName = partialName + ";" + num2str(ii)
600                        Open/Z/R/T="????TEXT"/P=catPathName refnum tempName
601                        if(V_flag == 0)
602                                //file exists
603                                Close refnum
604                                break
605                        endif
606                Endif
607                ii+=1
608                //print "ii=",ii
609        while(ii<11)
610        //go get the selected bits of information, using tempName, which exists
611        if(ii>=11)
612                //msg = partialName + " not found. is version number > 11?"
613                //DoAlert 0, msg
614                //PathInfo catPathName
615                //Print S_Path
616                Return ("")             //use null string as error condition
617        Endif
618       
619        Return (tempName)
620End
621
622//function to remove all spaces from names when searching for filenames
623//the filename (as saved) will never have interior spaces (TTTTTnnn_AB _Bnnn)
624//but the text field in the header WILL, if less than 3 characters were used for the
625//user's initials, and can have leading spaces if prefix was less than 5 characters
626//
627//returns a string identical to the original string, except with the interior spaces removed
628//
629Function/S A_RemoveAllSpaces(str)
630        String str
631       
632        String tempstr = str
633        Variable ii,spc,len             //should never be more than 2 or 3 trailing spaces in a filename
634        ii=0
635        do
636                len = strlen(tempStr)
637                spc = strsearch(tempStr," ",0)          //is the last character a space?
638                if (spc == -1)
639                        break           //no more spaces found, get out
640                endif
641                str = tempstr
642                tempStr = str[0,(spc-1)] + str[(spc+1),(len-1)] //remove the space from the string
643        While(1)        //should never be more than 2 or 3
644       
645        If(strlen(tempStr) < 1)
646                tempStr = ""            //be sure to return a null string if problem found
647        Endif
648       
649        //Print strlen(tempstr)
650       
651        Return(tempStr)
652               
653End
Note: See TracBrowser for help on using the repository browser.