source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf @ 1002

Last change on this file since 1002 was 1002, checked in by srkline, 6 years ago

main changes here are the addition of a first pass at the file catalog, and patch panel. each of these is based on the old SANS file (for now) and has been updated to at least compile.

Much more work needs to be done to get the functionality to be what VSANS needs, both in what is important to report in the file catalog, and how to best present the patch GUI for different situations

  • Property svn:executable set to *
File size: 41.4 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=6.1
4
5
6//
7// Updated for use with VSANS (in process)
8// -- currently very crude, and needs to be changed to accomodate the
9//   large number of parameters in the file that may/will need to be patched.
10// -- if this turns out to be too crude or too difficult to work with for what
11//   VSANS needs, I may ditch the entire procedure and start fresh
12//
13// June 2016 SRK
14//
15
16// TODOs have been inserted to comment out all of the calls that don't compile and need to be replaced
17
18// TODO
19// -- not all of the functions here have been prefixed with "V_", especially the action procedures from the panel
20//   so this cannot be opened with the SANS Reduction, or there will be clashes
21// -- same file load/reload issue as with other operations that read a field from the file. ANY read requires
22//   that the entire file is read in, even just to check and see if it's raw data... then there is a local
23//   copy present to confuse matters of what was actually written
24//
25// -- for the batch entering of fields, when all of the proper beam center values are determined, then
26//    all (2 x 9 = 18) of these values will need to be entered in all of the data files that "match" this
27//    "configuration" - however a configuration is to be defined and differentiated from other configurations.
28//
29// -- there may be other situations where batch entering needs are
30//               different, and this may lead to different interface choices
31//
32//
33
34
35//**************************
36// Vers. 1.2 092101
37//
38//procedures required to allow patching of raw SANS data headers
39//only a limited number of fields are allowable for changes, although the list could
40//be enhanced quite easily, at the expense of a larger, more complex panel
41//information for the Patch Panel is stored in the root:Packages:NIST:VSANS:Globals:Patch subfolder
42//
43// writes changes directly to the raw data headers as requested
44// * note that if a data file is currently in a work folder, the (real) header on disk
45// will be updated, but the data in the (WORK) folder will not reflect these changes, unless
46// the data folder is first cleared and the data is re-loaded
47//
48//**************************
49
50//main entry procedure for displaying the Patch Panel
51//
52Proc V_PatchFiles()
53       
54        DoWindow/F V_Patch_Panel
55        If(V_flag == 0)
56                V_InitializePatchPanel()
57                //draw panel
58                V_Patch_Panel()
59        Endif
60End
61
62//initialization of the panel, creating the necessary data folder and global
63//variables if necessary - simultaneously initialize the globals for the Trans
64//panel at this time, to make sure they all exist
65//
66// root:Packages:NIST:VSANS:Globals:
67Proc V_InitializePatchPanel()
68        //create the global variables needed to run the Patch Panel
69        //all are kept in root:Packages:NIST:VSANS:Globals:Patch
70        If( ! (DataFolderExists("root:Packages:NIST:VSANS:Globals:Patch"))  )
71                //create the data folder and the globals for BOTH the Patch and Trans panels
72                NewDataFolder/O root:Packages:NIST:VSANS:Globals:Patch
73        Endif
74        V_CreatePatchGlobals()          //re-create them every time (so text and radio buttons are correct)
75End
76
77//the data folder root:Packages:NIST:VSANS:Globals:Patch must exist
78//
79Proc V_CreatePatchGlobals()
80        //ok, create the globals
81        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr = "*"
82        PathInfo catPathName
83        If(V_flag==1)
84                String dum = S_path
85                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
86        else
87                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no path selected"
88        endif
89        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = "none"
90        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1 = "no file selected"
91        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS2 = "no file selected"
92        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS3 = "no box selected"
93        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV1 =0
94        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV2 = 0
95        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV3 = 0
96        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV4 = 0
97        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV5 = 0
98        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV6 = 0
99        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV7 = 0
100        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV8 = 0
101        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV9 = 0
102        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV10 = 0
103        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV11 = 0
104        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV12 = 0
105        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV13 = 0
106        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV14 = 0
107        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV15 = 0
108        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV16 = 0
109        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV17 = 0
110        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV18 = 0
111        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV19 = 0
112        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gTransCts = 0
113        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gRadioVal = 1
114End
115
116//button action procedure to select the local path to the folder that
117//contains the SANS data
118//sets catPathName, updates the path display and the popup of files (in that folder)
119//
120Function V_PickPathButton(PathButton) : ButtonControl
121        String PathButton
122       
123        //set the global string to the selected pathname
124        V_PickPath()
125        //set a local copy of the path for Patch
126        PathInfo/S catPathName
127        String dum = S_path
128        if (V_flag == 0)
129                //path does not exist - no folder selected
130                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no folder selected"
131        else
132                String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum
133        endif
134       
135        //Update the pathStr variable box
136        ControlUpdate/W=V_Patch_Panel $"PathDisplay"
137       
138        //then update the popup list
139        // (don't update the list - not until someone enters a search critera) -- Jul09
140        //
141        SetMatchStrProc("",0,"*","")            //this is equivalent to finding everything, typical startup case
142
143End
144
145
146//returns a list of valid files (raw data, no version numbers, no averaged files)
147//that is semicolon delimited, and is suitable for display in a popup menu
148//
149Function/S xGetValidPatchPopupList()
150
151        //make sure that path exists
152        PathInfo catPathName
153        String path = S_path
154        if (V_flag == 0)
155                Abort "folder path does not exist - use Pick Path button"
156        Endif
157       
158        String newList = ""
159
160        newList = V_GetRawDataFileList()
161
162        //trim list to include only selected files
163        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
164        if(strlen(match) == 0)          //if nothing is entered for a match string, return everything, rather than nothing
165                match = "*"
166        endif
167
168        newlist = V_MyMatchList(match,newlist,";")
169       
170        newList = SortList(newList,";",0)
171        Return(newList)
172End
173
174//returns a list of valid files (raw data, no version numbers, no averaged files)
175//that is semicolon delimited, and is suitable for display in a popup menu
176//
177// Uses Grep to look through the any text in the file, which includes the sample label
178// can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit
179// enter when inputing a filter string)
180//
181// - or -
182// a list or range of run numbers
183// - or -
184// a SDD (to within 0.001m)
185// - or -
186// * to get everything
187//
188//      NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
189 // 1== Run # (comma range OK)
190 // 2== Grep the text (SLOW)
191 // 3== filter by SDD (within 0.001 m)
192Function/S GetValidPatchPopupList()
193
194        //make sure that path exists
195        PathInfo catPathName
196        String path = S_path
197        if (V_flag == 0)
198                Abort "folder path does not exist - use Pick Path button"
199        Endif
200       
201        String newList = ""
202
203        newList = V_GetRawDataFileList()
204
205        //trim list to include only selected files
206        SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
207        if(strlen(match) == 0 || cmpstr(match,"*")==0)          //if nothing or "*" entered for a match string, return everything, rather than nothing
208                match = "*"
209        // old way, with simply a wildcard
210                newlist = V_MyMatchList(match,newlist,";")
211                newList = SortList(newList,";",0)
212                return(newList)
213        endif
214       
215        //loop through all of the files as needed
216
217       
218        String list="",item="",fname,runList="",numStr=""
219        Variable ii,num=ItemsInList(newList),val,sdd
220        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
221       
222
223
224        // run number list
225        if(gRadioVal == 1)
226//              list = ParseRunNumberList(match)                //slow, file access every time
227//              list = ReplaceString(",", list, ";")
228//              newList = list
229
230// cut this 0ct 2014 -- the ListMatch at the bottom returns bad results when certain conditions are met:
231// -- for example OCT14nnn runs will return all of the OCT141nn runs if you try to match run 141
232//
233//             
234//              list = ExpandNumRanges(match)           //now simply comma delimited
235//              num=ItemsInList(list,",")
236//              for(ii=0;ii<num;ii+=1)
237//                      item = StringFromList(ii,list,",")
238//                      val=str2num(item)
239//                      //make a three character string of the run number
240//                      if(val<10)
241//                              numStr = "00"+num2str(val)
242//                      else
243//                              if(val<100)
244//                                      numStr = "0"+num2str(val)
245//                              else
246//                                      numStr = num2str(val)
247//                              Endif
248//                      Endif
249//                      runList += ListMatch(newList,"*"+numStr+"*",";")
250//                     
251//              endfor         
252               
253// oct 2014 -- try this way:   
254// TODO -- replace call
255//              list = ExpandNumRanges(match)           //now simply comma delimited
256                num=ItemsInList(list,",")
257                for(ii=0;ii<num;ii+=1)
258                        item = StringFromList(ii,list,",")
259                        val=str2num(item)
260
261// TODO -- replace call
262//                      runList += GetFileNameFromPathNoSemi(FindFileFromRunNumber(val)) + ";"
263                       
264                endfor
265                newlist = runList
266               
267        endif
268       
269        //grep through what text I can find in the VAX binary
270        // Grep Note: the \\b sequences limit matches to a word boundary before and after
271        // "boondoggle", so "boondoggles" and "aboondoggle" won't match.
272        if(gRadioVal == 2)
273                for(ii=0;ii<num;ii+=1)
274                        item=StringFromList(ii, newList , ";")
275//                      Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item
276                        Grep/P=catPathName/Q/E=("(?i)"+match) item
277                        if( V_value )   // at least one instance was found
278//                              Print "found ", item,ii
279                                list += item + ";"
280                        endif
281                endfor
282
283                newList = list
284        endif
285       
286        // SDD
287        Variable pos
288        String SDDStr=""
289        if(gRadioVal == 3)
290                pos = strsearch(match, "*", 0)
291                if(pos == -1)           //no wildcard
292                        val = str2num(match)
293                else
294                        val = str2num(match[0,pos-1])
295                endif
296               
297//              print val
298                for(ii=0;ii<num;ii+=1)
299                        item=StringFromList(ii, newList , ";")
300                        fname = path + item
301// TODO -- replace call
302//                      sdd = getSDD(fname)
303                        if(pos == -1)
304                                //no wildcard
305                                if(abs(val - sdd) < 0.01        )               //if numerically within 0.01 meter, they're the same
306                                        list += item + ";"
307                                endif
308                        else
309                                //yes, wildcard, try a string match?
310                                // string match doesn't work -- 1* returns 1m and 13m data
311                                // round the value (or truncate?)
312                               
313                                //SDDStr = num2str(sdd)
314                                //if(strsearch(SDDStr,match[0,pos-1],0) != -1)
315                                //      list += item + ";"
316                                //endif
317                               
318                                if(abs(val - round(sdd)) < 0.01 )               //if numerically within 0.01 meter, they're the same
319                                        list += item + ";"
320                                endif
321       
322                        endif
323                endfor
324               
325                newList = list
326        endif
327
328        newList = SortList(newList,";",0)
329        Return(newList)
330End
331
332
333
334
335// -- no longer refreshes the list - this seems redundant, and can be slow if grepping
336//
337//updates the popup list when the menu is "popped" so the list is
338//always fresh, then automatically displays the header of the popped file
339//value of match string is used in the creation of the list - use * to get
340//all valid files
341//
342Function PatchPopMenuProc(PatchPopup,popNum,popStr) : PopupMenuControl
343        String PatchPopup
344        Variable popNum
345        String popStr
346
347        //change the contents of gPatchList that is displayed
348        //based on selected Path, match str, and
349        //further trim list to include only RAW SANS files
350        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched)
351
352//      String list = GetValidPatchPopupList()
353       
354//      String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
355//      ControlUpdate PatchPopup
356        ShowHeaderButtonProc("SHButton")
357End
358
359//when text is entered in the match string, the popup list is refined to
360//include only the selected files, useful for trimming a lengthy list, or selecting
361//a range of files to patch
362//only one wildcard (*) is allowed
363//
364Function SetMatchStrProc(ctrlName,varNum,varStr,varName) : SetVariableControl
365        String ctrlName
366        Variable varNum
367        String varStr
368        String varName
369
370        //change the contents of gPatchList that is displayed
371        //based on selected Path, match str, and
372        //further trim list to include only RAW SANS files
373        //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched)
374       
375        String list = GetValidPatchPopupList()
376       
377        String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list
378        ControlUpdate PatchPopup
379        PopupMenu PatchPopup,mode=1
380       
381        if(strlen(list) > 0)
382                ShowHeaderButtonProc("SHButton")
383        endif
384End
385
386
387//displays the header of the selected file (top in the popup) when the button is clicked
388//sort of a redundant button, since the procedure is automatically called (as if it were
389//clicked) when a new file is chosen from the popup
390//
391Function ShowHeaderButtonProc(SHButton) : ButtonControl
392        String SHButton
393
394        //displays (editable) header information about current file in popup control
395        //putting the values in the SetVariable displays (resetting the global variables)
396       
397        //get the popup string
398        String partialName, tempName
399        Variable ok
400        ControlInfo/W=V_Patch_Panel PatchPopup
401        If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0)
402                //null selection
403                Abort "no file selected in popup menu"
404        else
405                //selection not null
406                partialName = S_value
407                //Print partialName
408        Endif
409        //get a valid file based on this partialName and catPathName
410        tempName = V_FindValidFilename(partialName)
411       
412        //prepend path to tempName for read routine
413        PathInfo catPathName
414        tempName = S_path + tempName
415       
416        //make sure the file is really a RAW data file
417        ok = V_CheckIfRawData(tempName)
418        if (!ok)
419                Abort "this file is not recognized as a RAW SANS data file"
420        Endif
421       
422        //Print tempName
423       
424        ReadHeaderForPatch(tempName)
425       
426        ControlUpdate/A/W=V_Patch_Panel
427       
428End
429
430//utility function that polls the checkboxes of the editable parameters
431//returns a wave with the yes/no checked state of the boxes
432// 0 = not checked (user does NOT want this header value updated)
433// 1 = checked (YES, change this value in the header)
434//num (input) is a simple check to make sure that the wave is set up properly
435//from the calling routine
436//
437Function GetCheckBoxesState(w,num)
438        Wave w     //on return, this wave contains the current state of the checkboxes
439        Variable num
440       
441        if(num != 20)
442                Abort "wrong number of checkboxes GetCheckBoxesState()"
443        Endif
444        ControlInfo checkPS1
445        w[0] = V_value
446       
447        Variable ii
448        String baseStr="checkPV"
449       
450        ii=1
451        do
452                ControlInfo $(baseStr + num2str(ii))
453                w[ii] = V_Value
454                ii+=1
455        while(ii<num)
456        return(0)
457End
458
459//on return, wt is a TEXT wave with the values in the SetVar boxes
460//will poll the SetVariable controls to get the new values - will get all the values,
461//and let the writing routine decide which ones it will actually use
462//num (input) is a simple check to make sure that the wave is set up properly
463//from the calling routine
464//
465Function GetEditedSetVarBoxes(wt,num)
466        Wave/T wt         
467        Variable num
468       
469        if(num != 20)
470                Abort "wrong number of checkboxes GetEditedSetVarBoxes()"
471        Endif
472        //pass all as a text wave - so only one wave has to be passed (conversion 2x, though)
473        //global is set to the changed value when entered. read others directly from the control
474        //make sure the text label is exactly 60 characters long, to match VAX field length
475        SVAR dum=root:Packages:NIST:VSANS:Globals:Patch:gPS1
476        String str60="", junk="junk"
477        str60 = PadString(junk,60,0x20)
478        if(strlen(dum) <= 60)
479                if(strlen(dum) == 60)
480                   str60 = dum
481                else
482                   str60 = PadString(dum,60,0x20)
483                Endif
484        else
485                //too long, truncate
486                str60[0,59] = dum[0,59]
487        Endif
488       
489        wt[0] = str60
490       
491        Variable ii
492        String baseStr="PV"
493        ii=1
494        do
495                ControlInfo $(baseStr + num2str(ii))
496                wt[ii] = num2str(V_Value)
497                ii+=1
498        while(ii<num)
499       
500        return(0)       //no error
501End
502
503
504//simple function to get the string value from the popup list of filenames
505//returned string is only the text in the popup, a partial name with no path
506//or VAX version number.
507//
508Function/S GetPatchPopupString()
509
510        String str=""
511       
512        ControlInfo patchPopup
513        If(cmpstr(S_value,"")==0)
514                //null selection
515                Abort "no file selected in popup menu"
516        else
517                //selection not null
518                str = S_value
519                //Print str
520        Endif
521       
522        Return str
523End
524
525//Changes (writes to disk!) the specified changes to the (single) file selected in the popup
526//reads the checkboxes to determine which (if any) values need to be written
527//
528Function ChangeHeaderButtonProc(CHButton) : ButtonControl
529        String CHButton
530
531        //read the (20) checkboxes to determine what changes to make
532        //The order/length of these waves are crucial!, set by nvars     
533        String partialName="", tempName = ""
534        Variable ok,nvars = 20,ii
535       
536        Make/O/N=(nvars) tempChange
537        Wave w=tempchange
538        GetCheckBoxesState(w,nvars)
539        //Print "w[0] = ",w[0]
540       
541       
542        //Get the current values in each of the fields - to pass to Write() as a textwave
543        Make/O/T/N=(nvars) tempValues
544        Wave/T wt=tempValues
545        //initialize textwave
546        ii=0
547        do
548                wt[ii] = ""
549                ii+=1
550        while(ii<nvars)
551        GetEditedSetVarBoxes(wt,nvars)
552       
553        //get the popup string
554        partialName = GetPatchPopupString()
555       
556        //get a valid file based on this partialName and catPathName
557        tempName = V_FindValidFilename(partialName)
558       
559        //prepend path to tempName for read routine
560        PathInfo catPathName
561        tempName = S_path + tempName
562       
563        //make sure the file is really a RAW data file
564        ok = V_CheckIfRawData(tempName)
565        if (!ok)
566                Abort "this file is not recognized as a RAW SANS data file"
567        Endif
568       
569        //go write the changes to the file
570        WriteHeaderForPatch(tempName,w,wt)
571       
572        //clean up wave before leaving
573        KillWaves/Z w,wt
574       
575End
576
577//*****this function actually writes the data to disk*****
578//overwrites the specific bytes the the header that are to be changed
579//real values are written out mimicking VAX format, so that can be properly
580//re-read as raw binary VAX files.
581//if any additional fields are to be edited, the exact byte location must be known
582//
583Function WriteHeaderForPatch(fname,change,textVal)
584        String fname
585        Wave change
586        Wave/T textVal
587       
588        Variable refnum,num
589        String textstr
590
591// TODO:
592// -- currently I hard-wired a detector choice. This needs to be changed (somehow), with a better interface
593//
594        String detStr = "FL"
595
596       
597        //change the sample label ?
598        if(change[0])
599                V_writeSampleDescription(fname,textVal[0])
600        Endif
601       
602
603        if(change[1])           //sample transmission
604                num = str2num(textVal[1])
605                V_writeSampleTransmission(fname,num)
606        Endif
607        if(change[2])           //sample thickness
608                num = str2num(textVal[2])
609                V_writeSampleThickness(fname,num)
610        Endif
611        if(change[3])           //pixel X
612                num = str2num(textVal[3])
613                V_writeDet_beam_center_x(fname,detStr,num)              // TODO un-hard-wire
614        Endif
615        if(change[4])           // pixel Y
616                num = str2num(textVal[4])
617                V_writeDet_beam_center_y(fname,detStr,num)              // TODO un-hard-wire
618        Endif
619        if(change[5])           //attenuator number
620                num = str2num(textVal[5])
621                V_writeAtten_num_dropped(fname,num)
622        Endif
623        if(change[6])
624                num =str2num(textVal[6])
625                V_writeCount_time(fname,num)
626        Endif
627        if(change[7])    //monitor count
628                num = str2num(textVal[7])
629                V_writeMonitorCount(fname,num)
630        Endif
631        if(change[8])     //total detector count
632                num = str2num(textVal[8])
633                V_writeDet_IntegratedCount(fname,detStr,num)            // TODO un-hard-wire
634        Endif
635        if(change[9])      //trans det count
636                num = str2num(textVal[9])
637// TODO -- replace call
638//              WriteTransDetCountToHeader(fname,num)
639        Endif
640        if(change[10])      //wavelength
641                num = str2num(textVal[10])
642                V_writeWavelength(fname,num)
643        Endif
644        ///
645        if(change[11])      //wavelength spread
646                num = str2num(textVal[11])
647                V_writeWavelength_spread(fname,num)
648        Endif
649        if(change[12])      //temperature
650                num = str2num(textVal[12])
651// TODO -- replace call
652//              WriteTemperatureToHeader(fname,num)
653        Endif
654        if(change[13])      //magnetic field
655                num = str2num(textVal[13])
656// TODO -- replace call
657//              WriteMagnFieldToHeader(fname,num)
658        Endif
659        if(change[14])      //source aperture
660//              num = str2num(textVal[14])
661                V_writeSourceAp_size(fname,textVal[14])         //this is expecting a string
662        Endif
663        if(change[15])      //sample aperture
664                num = str2num(textVal[15])
665                V_writeSampleAp2_size(fname,num)                //TODO -- not sure if this is correct call
666        Endif
667        ///
668        if(change[16])      //source-sam dist
669                num = str2num(textVal[16])
670// TODO -- replace call
671//              WriteSrcToSamDistToHeader(fname,num)
672        Endif
673        if(change[17])      //det offset
674                num = str2num(textVal[17])
675                V_writeDet_LateralOffset(fname,detStr,num)              // TODO lateral or vertical offset, based on detStr
676        Endif
677        if(change[18])      //beamstop diam
678                num = str2num(textVal[18])
679                V_writeBeamStopC2_size(fname,num)                       //TODO depends on which det carriage I'm working with (2) or (3)
680        Endif
681        if(change[19])     //SDD
682                num = str2num(textVal[19])
683                V_writeDet_distance(fname,detStr,num)   // TODO un-hard-wire
684        Endif
685        Return(0)
686End
687
688//panel recreation macro for the PatchPanel...
689//
690Proc V_Patch_Panel()
691        PauseUpdate; Silent 1      // building window...
692        NewPanel /W=(519,85,950,608)/K=1 as "Patch Raw VSANS Data Files"
693//      NewPanel /W=(519,85,950,608) as "Patch Raw SANS Data Files"
694        DoWindow/C V_Patch_Panel
695        ModifyPanel cbRGB=(1,39321,19939)
696        ModifyPanel fixedSize=1
697        SetDrawLayer UserBack
698        SetDrawEnv fname= "Courier",fstyle= 1
699        DrawText 3,107,"Change?"
700        DrawLine 7,30,422,30
701        DrawLine 7,288,422,288
702        DrawLine 7,199,422,199
703        DrawLine 7,378,422,378
704        DrawLine 7,469,422,469
705        SetVariable PathDisplay,pos={77,7},size={310,13},title="Path"
706        SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while patching. If no files appear in the popup, make sure that this folder is set correctly"}
707        SetVariable PathDisplay,font="Courier",fSize=10
708        SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr
709        Button PathButton,pos={2,3},size={70,20},proc=PickPathButton,title="Pick Path"
710        Button PathButton,help={"Select the folder containing the raw SANS data files"}
711        Button helpButton,pos={400,3},size={25,20},proc=ShowPatchHelp,title="?"
712        Button helpButton,help={"Show the help file for patching raw data headers"}
713        PopupMenu PatchPopup,pos={4,37},size={156,19},proc=PatchPopMenuProc,title="File(s) to Patch"
714        PopupMenu PatchPopup,help={"The displayed file is the one that will be edited. The entire list will be edited if \"Change All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh. \r List items are selected from the file based on MatchString"}
715        PopupMenu PatchPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:Patch:gPatchList"
716//      Button SHButton,pos={324,37},size={100,20},proc=ShowHeaderButtonProc,title="Show Header"
717//      Button SHButton,help={"This will display the header of the file indicated in the popup menu."}
718        Button CHButton,pos={314,37},size={110,20},proc=ChangeHeaderButtonProc,title="Change Header"
719        Button CHButton,help={"This will change the checked values (ONLY) in the single file selected in the popup."}
720        SetVariable PMStr,pos={6,63},size={174,13},proc=SetMatchStrProc,title="Match String"
721        SetVariable PMStr,help={"Enter the search string to narrow the list of files. \"*\" is the wildcard character. After entering, \"pop\" the menu to refresh the file list."}
722        SetVariable PMStr,font="Courier",fSize=10
723        SetVariable PMStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr
724        Button ChAllButton,pos={245,60},size={180,20},proc=ChAllHeadersButtonProc,title="Change All Headers in List"
725        Button ChAllButton,help={"This will change the checked values (ONLY) in ALL of the files in the popup list, not just the top file. If the \"change\" checkbox for the item is not checked, nothing will be changed for that item."}
726        Button DoneButton,pos={310,489},size={110,20},proc=DoneButtonProc,title="Done Patching"
727        Button DoneButton,help={"When done Patching files, this will close this control panel."}
728        Button cat_short,pos={9,485},size={100,20},proc=DoCatShort,title="File Catalog"
729        Button cat_short,help={"Use this button to generate a notebook with file header information. Very useful for identifying files."}
730        SetVariable PS1,pos={42,111},size={338,13},proc=SetLabelVarProc,title="label"
731        SetVariable PS1,help={"Current sample label"},font="Courier",fSize=10
732        SetVariable PS1,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPS1
733        SetVariable PV1,pos={42,129},size={340,13},title="Transmission"
734        SetVariable PV1,help={"Current transmission\rvalue"},font="Courier",fSize=10
735        SetVariable PV1,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV1
736        SetVariable PV2,pos={42,147},size={340,13},title="Thickness (cm)"
737        SetVariable PV2,help={"Current sample thickness, in units of centimeters"}
738        SetVariable PV2,font="Courier",fSize=10
739        SetVariable PV2,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV2
740        SetVariable PV3,pos={42,165},size={340,13},title="Beamcenter X"
741        SetVariable PV3,help={"Current X-position of the beamcenter, in pixels"}
742        SetVariable PV3,font="Courier",fSize=10
743        SetVariable PV3,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV3
744        SetVariable PV4,pos={42,183},size={340,13},title="Beamcenter Y"
745        SetVariable PV4,help={"Current Y-position of the beamcenter, in pixels"}
746        SetVariable PV4,font="Courier",fSize=10
747        SetVariable PV4,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV4
748        SetVariable PV5,pos={42,202},size={340,13},title="Attenuator number"
749        SetVariable PV5,help={"attenuator number present during data collection"}
750        SetVariable PV5,font="Courier",fSize=10
751        SetVariable PV5,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV5
752        SetVariable PV6,pos={42,219},size={340,13},title="Counting time (s)",font="Courier",fSize=10
753        SetVariable PV6,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV6
754        SetVariable PV6,help={"total counting time in seconds"}
755        SetVariable PV7,pos={42,237},size={340,13},title="Monitor count",font="Courier",fSize=10
756        SetVariable PV7,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV7
757        SetVariable PV7,help={"total monitor counts"}
758        SetVariable PV8,pos={42,255},size={340,13},title="Detector count",font="Courier",fSize=10
759        SetVariable PV8,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV8
760        SetVariable PV8,help={"total detector counts"}
761        SetVariable PV9,pos={42,273},size={340,13},title="Trans. det. count",font="Courier",fSize=10
762        SetVariable PV9,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV9
763        SetVariable PV9,help={"Transmission\r detector counts"}
764        SetVariable PV10,pos={42,291},size={340,13},title="Wavelength (A)",font="Courier",fSize=10
765        SetVariable PV10,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV10
766        SetVariable PV10,help={"neutron wavelength in angstroms"}
767        SetVariable PV11,pos={42,309},size={340,13},title="Wavelength spread (dL/L)",font="Courier",fSize=10
768        SetVariable PV11,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV11
769        SetVariable PV11,help={"wavelength spread (delta lambda)/lambda"}
770        SetVariable PV12,pos={42,327},size={340,13},title="Temperature (C)",font="Courier",fSize=10
771        SetVariable PV12,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV12
772        SetVariable PV12,help={"Set point temperature in centigrade"}
773        SetVariable PV13,pos={42,345},size={340,13},title="Magnetic field (G)",font="Courier",fSize=10
774        SetVariable PV13,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV13
775        SetVariable PV13,help={"magnetic field strength units?"}
776        SetVariable PV14,pos={42,363},size={340,13},title="Source aperture diameter (mm)",font="Courier",fSize=10
777        SetVariable PV14,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV14
778        SetVariable PV14,help={"source aperture diameter, in millimeters"}
779        SetVariable PV15,pos={42,381},size={340,13},title="Sample aperture diameter (mm)",font="Courier",fSize=10
780        SetVariable PV15,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV15
781        SetVariable PV15,help={"sample aperture diameter, in millimeters"}
782        SetVariable PV16,pos={42,399},size={340,13},title="Source to sample distance (m)",font="Courier",fSize=10
783        SetVariable PV16,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV16
784        SetVariable PV16,help={"Source to sample distance in meters"}
785        SetVariable PV17,pos={42,417},size={340,13},title="Detector offset (cm)",font="Courier",fSize=10
786        SetVariable PV17,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV17
787        SetVariable PV17,help={"Detector offset, in centimeters"}
788        SetVariable PV18,pos={42,435},size={340,13},title="Beamstop diameter (mm)",font="Courier",fSize=10
789        SetVariable PV18,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV18
790        SetVariable PV18,help={"beamstop diamter, in millimeters (1 inch = 25.4mm)"}
791        SetVariable PV19,pos={42,453},size={340,13},title="Sample to detector distance (m)",font="Courier",fSize=10
792        SetVariable PV19,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPV19
793        SetVariable PV19,help={"sample to detector distance, in meters"}
794       
795        CheckBox checkPS1,pos={18,108},size={20,20},title=""
796        CheckBox checkPS1,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
797        CheckBox checkPV1,pos={18,126},size={20,20},title=""
798        CheckBox checkPV1,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
799        CheckBox checkPV2,pos={18,144},size={20,20},title=""
800        CheckBox checkPV2,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
801        CheckBox checkPV3,pos={18,162},size={20,20},title=""
802        CheckBox checkPV3,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
803        CheckBox checkPV4,pos={18,180},size={20,20},title=""
804        CheckBox checkPV4,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
805        CheckBox checkPV5,pos={18,198},size={20,20},title=""
806        CheckBox checkPV5,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
807        CheckBox checkPV6,pos={18,216},size={20,20},title=""
808        CheckBox checkPV6,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
809        CheckBox checkPV7,pos={18,234},size={20,20},title="",value=0
810        CheckBox checkPV7,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
811        CheckBox checkPV8,pos={18,252},size={20,20},title="",value=0
812        CheckBox checkPV8,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
813        CheckBox checkPV9,pos={18,270},size={20,20},title="",value=0
814        CheckBox checkPV9,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
815        CheckBox checkPV10,pos={18,288},size={20,20},title="",value=0
816        CheckBox checkPV10,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
817        CheckBox checkPV11,pos={18,306},size={20,20},title="",value=0
818        CheckBox checkPV11,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
819        CheckBox checkPV12,pos={18,324},size={20,20},title="",value=0
820        CheckBox checkPV12,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
821        CheckBox checkPV13,pos={18,342},size={20,20},title="",value=0
822        CheckBox checkPV13,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
823        CheckBox checkPV14,pos={18,360},size={20,20},title="",value=0
824        CheckBox checkPV14,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
825        CheckBox checkPV15,pos={18,378},size={20,20},title="",value=0
826        CheckBox checkPV15,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
827        CheckBox checkPV16,pos={18,396},size={20,20},title="",value=0
828        CheckBox checkPV16,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
829        CheckBox checkPV17,pos={18,414},size={20,20},title="",value=0
830        CheckBox checkPV17,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
831        CheckBox checkPV18,pos={18,432},size={20,20},title="",value=0
832        CheckBox checkPV18,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
833        CheckBox checkPV19,pos={18,450},size={20,20},title="",value=0
834        CheckBox checkPV19,help={"If checked, the entered value will be written to the data file if either of the \"Change..\" buttons is pressed."},value=0
835
836        CheckBox check0,pos={18,80},size={40,15},title="Run #",value= 1,mode=1,proc=MatchCheckProc
837        CheckBox check1,pos={78,80},size={40,15},title="Text",value= 0,mode=1,proc=MatchCheckProc
838        CheckBox check2,pos={138,80},size={40,15},title="SDD",value= 0,mode=1,proc=MatchCheckProc
839
840End
841
842
843Function MatchCheckProc(name,value)
844        String name
845        Variable value
846       
847        NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal
848       
849        strswitch (name)
850                case "check0":
851                        gRadioVal= 1
852                        break
853                case "check1":
854                        gRadioVal= 2
855                        break
856                case "check2":
857                        gRadioVal= 3
858                        break
859        endswitch
860        CheckBox check0,value= gRadioVal==1
861        CheckBox check1,value= gRadioVal==2
862        CheckBox check2,value= gRadioVal==3
863End
864
865//This function will read only the selected values editable in the patch panel
866//The values read are passed to the panel through the global variables
867//the function WriteHeaderForPatch() MUST mirror this set of reads, or nothing can be updated
868//
869//fname is the full path:name;vers to open the file
870//
871Function ReadHeaderForPatch(fname)
872        String fname
873       
874        //assign to the globals for display in the panel
875
876        // TODO -- replace ALL (get) calls below
877        // TODO -- verify that these calls are really returning what is expected by the checkbox label
878        // -- some are clearly wrong for VSANS
879       
880        // TODO -- remove the hard-wired detStr. This will require some serious interface thought.
881        String detStr = "FL"
882       
883        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1= V_getSampleDescription(fname)
884        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV1 = V_getSampleTransmission(fname)
885        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV2 = V_getSampleThickness(fname)
886        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV3 = V_getDet_beam_center_x(fname,detStr)
887        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV4 = V_getDet_beam_center_y(fname,detStr)
888        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV5 = V_getAtten_Number(fname)
889        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV6 = V_getCount_Time(fname)
890        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV7 = V_getMonitorCount(fname)
891        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV8 = V_getDet_IntegratedCount(fname,detStr)
892        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV9 = -999           // TODO no equivalent for VSANS to --getTransDetectorCounts(fname)
893        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV10 = V_getWavelength(fname)
894        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV11 = V_getWavelength_Spread(fname)
895        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV12 = -999 // TODO no equivalent yet for -- getTemperature(fname)
896        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV13 = -999 // TODO no equivalent yet for -- getFieldStrength(fname)
897        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV14 = str2num(V_getSourceAp_size(fname))
898        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV15 = V_getSampleAp2_size(fname)
899        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV16 = -999 // TODO no equivalent yet for -- getSourceToSampleDist(fname)
900        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV17 = V_getDet_LateralOffset(fname,detStr)  //TODO lateral vs vertical offset
901        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV18 = V_getBeamStopC3_size(fname)
902        Variable/G root:Packages:NIST:VSANS:Globals:Patch:gPV19 = V_getDet_ActualDistance(fname,detStr)
903       
904        Return 0
905End
906
907Function ShowPatchHelp(ctrlName) : ButtonControl
908        String ctrlName
909//      DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[Patch File Headers]"
910//      if(V_flag !=0)
911                DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found"
912//      endif
913End
914
915//button action procedure to change the selected information (checked values)
916//in each file in the popup list. This will change multiple files, and as such,
917//the user is given a chance to bail out before the whole list of files
918//is modified
919//useful for patching a series of runs with the same beamcenters, or transmissions
920//
921Function ChAllHeadersButtonProc(ctrlName) : ButtonControl
922        String ctrlName
923       
924        String msg
925        msg = "Do you really want to write all of these values to each data file in the popup list? "
926        msg += "- clicking NO will leave all files unchanged"
927        DoAlert 1,msg
928        If(V_flag == 2)
929                Abort "no files were changed"
930        Endif
931       
932        //this will change (checked) values in ALL of the headers in the popup list
933        SVAR list = root:Packages:NIST:VSANS:Globals:Patch:gPatchList
934        Variable numitems,ii
935        numitems = ItemsInList(list,";")
936       
937        if(numitems == 0)
938                Abort "no items in list for multiple patch"
939        Endif
940       
941        //read the (6) checkboxes to determine what changes to make
942        //The order/length of these waves are crucial!, set by nvars     
943        String partialName="", tempName = ""
944        Variable ok,nvars = 20
945       
946        Make/O/N=(nvars) tempChange
947        Wave w=tempchange
948        GetCheckBoxesState(w,nvars)
949        //Print "w[0] = ",w[0]
950       
951        //Get the current values in each of the fields - to pass to Write() as a textwave
952        Make/O/T/N=(nvars) tempValues
953        Wave/T wt=tempValues
954        //initialize textwave
955        ii=0
956        do
957                wt[ii] = ""
958                ii+=1
959        while(ii<nvars)
960        GetEditedSetVarBoxes(wt,nvars)
961       
962        //loop through all of the files in the list, applying changes as dictated by w and wt waves
963        ii=0
964        do
965                //get current item in the list
966                partialName = StringFromList(ii, list, ";")
967                   
968                //get a valid file based on this partialName and catPathName
969                tempName = V_FindValidFilename(partialName)
970       
971                //prepend path to tempName for read routine
972                PathInfo catPathName
973                tempName = S_path + tempName
974       
975                //make sure the file is really a RAW data file
976                ok = V_CheckIfRawData(tempName)
977                if (!ok)
978                   Print "this file is not recognized as a RAW SANS data file = ",tempName
979                else
980                   //go write the changes to the file
981                   WriteHeaderForPatch(tempName,w,wt)
982                Endif
983               
984                ii+=1
985        while(ii<numitems)
986       
987        //clean up wave before leaving
988        KillWaves/Z w,wt
989               
990End
991
992
993//simple action for button to close the panel
994Function DoneButtonProc(ctrlName) : ButtonControl
995        String ctrlName
996       
997        DoWindow/K V_Patch_Panel
998       
999End
1000
1001//resets the global string corresponding to the sample label
1002//updates when new text is entered
1003//
1004Function SetLabelVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl
1005        String ctrlName
1006        Variable varNum
1007        String varStr
1008        String varName
1009       
1010        //reset the global variable to the entered text so that it can be relayed to the
1011        //write() routine. Only the TEXT SetVariable control needs to be handled this way
1012       
1013        String/G root:Packages:NIST:VSANS:Globals:Patch:gPS1 = varStr
1014
1015End
1016
1017
1018// testing, very dangerous batch changing of the file header labels
1019//
1020// testStr is the string at the front of a label, that will be moved to the "back"
1021// if doIt is 1, it will write to the headers, any other value will only print to history
1022Function xMPatchLabel(testStr,doIt)
1023        String testStr
1024        Variable doIt
1025
1026//      SVAR list = root:Packages:NIST:VSANS:Globals:Patch:gPatchList
1027        String list = GetValidPatchPopupList()
1028
1029        Variable numitems,ii
1030        numitems = ItemsInList(list,";")
1031       
1032        if(numitems == 0)
1033                Abort "no items in list for multiple patch"
1034        Endif
1035       
1036        String partialName="", tempName = ""
1037        Variable ok,nvars = 20
1038       
1039        //loop through all of the files in the list, applying changes as dictated by w and wt waves
1040        string str1,str2,str3
1041        Variable match,loc,len,spc,jj,len1
1042        len=strlen(testStr)
1043        ii=0
1044        do
1045                //get current item in the list
1046                partialName = StringFromList(ii, list, ";")
1047                   
1048                //get a valid file based on this partialName and catPathName
1049                tempName = V_FindValidFilename(partialName)
1050       
1051                //prepend path to tempName for read routine
1052                PathInfo catPathName
1053                tempName = S_path + tempName
1054       
1055                //make sure the file is really a RAW data file
1056                ok = V_CheckIfRawData(tempName)
1057                if (!ok)
1058                   Print "this file is not recognized as a RAW SANS data file = ",tempName
1059                else
1060                   //go write the changes to the file
1061                        str1 = V_getSampleDescription(tempName)
1062                        match = strsearch(str1, testStr, 0)
1063                        if(match != -1)
1064                                str2 = ReplaceString(testStr, str1, "", 0, 1)
1065                               
1066                                jj=strlen(str2)
1067                                do
1068                                        jj -= 1
1069                                        spc = cmpstr(str2[jj], " ")             //can add the optional flag ,0), but I don't care about case, and Igor 6.02 is necessary...
1070                                        if (spc != 0)
1071                                                break           //no more spaces found, get out
1072                                        endif
1073                                While(1)        // jj is the location of the last non-space
1074                               
1075                                str2[jj+2,jj+1+len] = testStr
1076                       
1077                        // may need to remove leading spaces???
1078                                str2 = PadString(str2, 60, 0x20 )
1079                               
1080                                if(doIt == 1)
1081                                        V_writeSampleDescription(tempName,str2)
1082                                        print str2," ** Written to file **"
1083                                else
1084                                        //print str2,strlen(str2)
1085                                        print str2," ** Testing, not written to file **"
1086                                endif
1087                        else
1088                               
1089                                jj=strlen(str1)
1090                                do
1091                                        jj -= 1
1092                                        spc = cmpstr(str1[jj], " ")
1093                                        if (spc != 0)
1094                                                break           //no more spaces found, get out
1095                                        endif
1096                                While(1)
1097       
1098                                //print str1, jj, str1[jj]     
1099                        endif
1100                Endif
1101               
1102                ii+=1
1103        while(ii<numitems)
1104
1105
1106end
Note: See TracBrowser for help on using the repository browser.