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

Last change on this file since 127 was 127, checked in by srkline, 16 years ago

LOTS of changes to the analysis ipf files:

-- see sphere.ipf for the simplest example of the changes --

  • #pragma Igor 6
  • #if directive to look for XOP
  • AAO unsmeared functions
  • STRUCT functions for smearing (also AAO)
  • new wrappers for dependencies to struct functions

(2006 models have NOT been completed yet, only the old models)

  • loading data files into data folders (PlotUtils?) + some streamlining of the loaders
  • Smear_Model_N is now AAO + some streamlining of the quadrature code

-- SHS and SW structure factor XOPs are crashing (need DP wave, I may have old XOP)
-- this breaks fitting of the smeared models until wrappers can be devised
-- all packages will be broken due to the new data folder structure
-- multiple instances of functions will now cause problems (MSA)
-- RPA model is a problem with its odd functional form (extra wave)

-- lots of other carnage to follow as the bugs and typos are shaken out

24 JUL 2007 SRK

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