source: sans/Dev/trunk/NCNR_User_Procedures/Common/Installer/NCNR_Install.ipf @ 644

Last change on this file since 644 was 644, checked in by srkline, 13 years ago

Tweaks for the installer.

File size: 21.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4
5
6///
7// ***********
8// it may be prefereable to COPY the files to the UP folder, so that the installer doesn't "eat" itself
9// and require users to re-download if they do something wrong. the difficulty with CopyFolder is that
10// on Windows it does a "mix-in" copy, rather than a delete/overwrite all. So it may be better to just leave
11// the installer as is, requiring a fresh copy each time. SRK 10MAR09
12//
13//
14///
15
16// Install the NCNR Macros
17
18//InstallNCNRMacros() // run this function when experiment is loaded
19//InstallerPanel() // run this function when experiment is loaded
20
21//
22// package-6.001
23// - lots more diagnostics added
24
25// FEB 2010 - now make use of the user-specific procedure path. It's always writeable, and not in the application folder
26//
27// since old material may be installed, and permission may be gone:
28// - check for permission
29// - check for old material installed in Igor Pro/
30// -- if nothing installed in Igor Pro/, then permissions are not a problem
31// -- install in the new uer-specific path as intended
32//
33// -- now I need to search both locations to move old stuff out
34// -- then install clean into the new user path (userPathStr)
35//
36
37Function InstallNCNRMacros(forceInstall)
38        Variable forceInstall           // if == 1, install whatever possible, even if R/W errors from the OS
39
40        //first step, check for Igor 6!!!
41        if(NumberByKey("IGORVERS", IgorInfo(0)) < 6)
42                Abort "You must be running Igor 6 or later to use these macros."
43        endif
44       
45       
46        // check to see if the installer has already been run... if so, the folders will be gone... stop now BEFORE removing things
47        String test = IndexedDir(home, -1, 0)   
48        if(stringmatch(test, "*NCNR_User_Procedures*") == 0)
49                print test
50                Abort "You've already run the installer. If you want to re-install, you'll need a fresh copy from the NCNR website."
51        endif
52       
53        // check for install problems
54        // locked folders, OS errors _err will be non-zero if there is an error
55        Variable UP_err,IH_err,IE_err
56        UP_err = FolderPermissionCheck("User Procedures:")
57        IH_err = FolderPermissionCheck("Igor Help Files:")
58        IE_err = FolderPermissionCheck("Igor Extensions:")     
59//      Print UP_err,IH_err,IE_err
60
61        String alertStr=""
62        if(UP_err != 0)
63                alertStr += "User Procedures has no write permission.\r"
64        endif
65        if(IH_err != 0)
66                alertStr += "Igor Help Files has no write permission.\r"
67        endif
68        if(IE_err != 0)
69                alertStr += "Igor Extensions has no write permission.\r"
70        endif
71
72/// SRK - 2010 - errors are not used here. instead, errors are caught if a file or folder move fails. If there
73// is nothing to move out, or it moves out OK, then permissions don't matter.
74       
75//      if(forceInstall == 0)
76//              if(UP_err != 0 || IH_err != 0 || IE_err != 0)
77//                      alertStr += "You will need to install manually."
78//                      DoAlert 0,alertStr
79//                      return(0)
80//              endif
81//      endif
82       
83       
84        // check the platform
85        Variable isMac=0
86        if(cmpstr("Macintosh",IgorInfo(2))==0)
87                isMac=1
88        endif
89       
90
91        String igorPathStr,homePathStr,userPathStr
92        PathInfo Igor
93        igorPathStr = S_Path            //these have trailing colons
94        PathInfo home                                   //the location where this was run from...
95        homePathStr = S_Path
96        // the Igor 6.1 User Procedure Path, same sub-folders as in Igor App Folder
97        userPathStr=RemoveEnding(SpecialDirPath("Igor Pro User Files",0,0,0),":")+":"
98       
99        // clean up old stuff, moving to home:old_moved_files
100        // extensions - these show up as files, even the aliases
101        // help files - these are files
102        // user procedures - these can be in folders or as files
103        variable i=0, AliasSet=0, isThere = 0
104        String tmpStr
105
106
107//////////////////////////////////////////////////////////////////////
108       
109////// clean up the Igor Extensions (first the old path -- in the App folder)
110        NewPath /Q/O ExPath, igorPathStr+"Igor Extensions:"
111        PathInfo ExPath
112        String extPathStr = S_Path
113        string strFileList = IndexedFile(ExPath, -1, "????" )
114       
115        //files first
116        Wave/T extFiles=root:IExtFiles
117        for (i=0; i<itemsInList(strFileList); i+=1)
118                tmpStr = StringFromList(i,strFileList)
119                isThere = CheckForMatch(tmpStr,extFiles)
120                if(isThere)
121                        MoveFile/O/P=ExPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
122                        Print "Move file "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
123                endif
124        endfor
125       
126        //then anything that shows up as a folder
127        Wave/T extFolders=root:IExtFolders
128        strFileList = IndexedDir(ExPath, -1, 0 )
129       
130        for (i=0; i<itemsInList(strFileList); i+=1)
131                tmpStr = StringFromList(i,strFileList)
132                isThere = CheckForMatch(tmpStr,extFolders)
133                if(isThere)
134                        MoveFolder extPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
135                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
136                endif
137        endfor
138
139////// then clean up the Igor Extensions (now look in the User Path, by changing the definition of ExPath)
140        NewPath /Q/O ExPath, userPathStr+"Igor Extensions:"
141        PathInfo ExPath
142        extPathStr = S_Path
143        strFileList = IndexedFile(ExPath, -1, "????" )
144               
145        for (i=0; i<itemsInList(strFileList); i+=1)
146                tmpStr = StringFromList(i,strFileList)
147                isThere = CheckForMatch(tmpStr,extFiles)
148                if(isThere)
149                        MoveFile/O/P=ExPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
150                        Print "Move file "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
151                endif
152        endfor
153       
154        //then anything that shows up as a folder
155        strFileList = IndexedDir(ExPath, -1, 0 )
156        for (i=0; i<itemsInList(strFileList); i+=1)
157                tmpStr = StringFromList(i,strFileList)
158                isThere = CheckForMatch(tmpStr,extFolders)
159                if(isThere)
160                        MoveFolder extPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
161                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
162                endif
163        endfor
164
165//////////////////////////////////////////////////////////////////////
166       
167/////// clean up the User Procedures -- in the APP folder
168        NewPath /Q/O UPPath, igorPathStr+"User Procedures:"
169        PathInfo UPPath
170        String UPPathStr = S_Path
171        strFileList = IndexedFile(UPPath, -1, "????" )                  //for files
172       
173        // (files first)
174        Wave/T UPFilesWave=root:UPFiles
175        for (i=0; i<itemsInList(strFileList); i+=1)
176                tmpStr = StringFromList(i,strFileList)
177                isThere = CheckForMatch(tmpStr,UPFilesWave)
178                if(isThere)
179                        MoveFile/O/P=UPPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
180                        Print "Move file "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
181                endif
182        endfor
183       
184        //(folders second)
185        strFileList = IndexedDir(UPPath, -1, 0)                 //for folders, just the names, not full paths
186        Wave/T UPFoldersWave=root:UPFolders
187       
188        for (i=0; i<itemsInList(strFileList); i+=1)
189                tmpStr = StringFromList(i,strFileList)
190                isThere = CheckForMatch(tmpStr,UPFoldersWave)
191                if(isThere)
192                // THIS is the problem, when NCNR_Help_Files is moved - it is in use
193                        MoveFolder/Z UPPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
194                        Print "Move folder "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
195                endif
196        endfor
197
198/////// now clean up the User Procedures -- in the User Folder
199        NewPath /Q/O UPPath, userPathStr+"User Procedures:"
200        PathInfo UPPath
201        UPPathStr = S_Path
202        strFileList = IndexedFile(UPPath, -1, "????" )                  //for files
203       
204        // (files first)
205        for (i=0; i<itemsInList(strFileList); i+=1)
206                tmpStr = StringFromList(i,strFileList)
207                isThere = CheckForMatch(tmpStr,UPFilesWave)
208                if(isThere)
209                        MoveFile/O/P=UPPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
210                        Print "Move file "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
211                endif
212        endfor
213       
214        //(folders second)
215        strFileList = IndexedDir(UPPath, -1, 0)                 //for folders, just the names, not full paths
216               
217        for (i=0; i<itemsInList(strFileList); i+=1)
218                tmpStr = StringFromList(i,strFileList)
219                isThere = CheckForMatch(tmpStr,UPFoldersWave)
220                if(isThere)
221                // THIS is the problem, when NCNR_Help_Files is moved - it is in use
222                        MoveFolder/Z UPPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
223                        Print "Move folder "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
224                endif
225        endfor
226
227
228//////////////////////////////////////////////////////////////////////
229
230
231
232/////// now try to clean up the Igor Help Files (in the APP folder)
233        NewPath /Q/O IHPath, igorPathStr+"Igor Help Files:"
234        PathInfo IHPath
235        String IHPathStr = S_Path
236        strFileList = IndexedFile(IHPath, -1, "????" )                  //for files
237       
238        // files first
239        Wave/T IHFilesWave=root:IHFiles
240       
241        for (i=0; i<itemsInList(strFileList); i+=1)
242                tmpStr = StringFromList(i,strFileList)
243                isThere = CheckForMatch(tmpStr,IHFilesWave)
244                if(isThere)
245                        MoveFile/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
246                        Print "Move file "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
247                endif
248        endfor 
249       
250        // then anything that shows up as a folder
251        Wave/T IHFilesWave=root:IHFolders
252        strFileList = IndexedDir(IHPath, -1, 0)
253       
254        for (i=0; i<itemsInList(strFileList); i+=1)
255                tmpStr = StringFromList(i,strFileList)
256                isThere = CheckForMatch(tmpStr,IHFolders)
257                if(isThere)
258                        MoveFolder IHPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
259                        Print "Move folder "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
260                endif
261        endfor
262       
263        /////// now try the Igor Help Files (in the USER folder)
264        NewPath /Q/O IHPath, userPathStr+"Igor Help Files:"
265        PathInfo IHPath
266        IHPathStr = S_Path
267        strFileList = IndexedFile(IHPath, -1, "????" )                  //for files
268       
269        // files first 
270        for (i=0; i<itemsInList(strFileList); i+=1)
271                tmpStr = StringFromList(i,strFileList)
272                isThere = CheckForMatch(tmpStr,IHFilesWave)
273                if(isThere)
274                        MoveFile/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
275                        Print "Move file "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
276                endif
277        endfor 
278       
279        // then anything that shows up as a folder
280        strFileList = IndexedDir(IHPath, -1, 0)
281       
282        for (i=0; i<itemsInList(strFileList); i+=1)
283                tmpStr = StringFromList(i,strFileList)
284                isThere = CheckForMatch(tmpStr,IHFolders)
285                if(isThere)
286                        MoveFolder IHPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
287                        Print "Move folder "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
288                endif
289        endfor
290
291
292
293// at this point all of the old stuff is cleaned up as best as I can
294//
295// at this point the paths point to the User Folder, not in the App folder     
296       
297       
298       
299       
300//////////// INSTALL the new stuff
301//
302//(1) copy the items to install to the User Special Folder
303//(2) --- now I don't need to set up aliases! they are just there
304//
305// the old ones should be gone already, so just put in the new ones
306
307// they may not be possible to remove, so try to overwrite...
308
309        NewPath /Q/O SpecialPath, userPathStr
310
311// the help files
312        MoveFolder/Z=1 homePathStr+"NCNR_Help_Files" as IHPathStr+"NCNR_Help_Files"
313        Print "******Move folder NCNR_Help_Files into User Special Folder, NO overwite: "+IsMoveOK(V_flag)
314
315// not needed now
316//      CreateAliasShortcut/O/P=SpecialPath "NCNR_Help_Files" as igorPathStr+"Igor Help Files:NCNR_Help_Files"
317//      Print "Creating shortcut from NCNR_Help_Files into Igor Help Files: "+IsMoveOK(V_flag)
318       
319
320// the User Procedures 
321        MoveFolder/Z=1 homePathStr+"NCNR_User_Procedures" as UPPathStr+"NCNR_User_Procedures"
322        Print "*******Move folder NCNR_User_Procedures into User Special Folder, NO overwrite: "+IsMoveOK(V_flag)
323       
324// don't need an alias for the UserProcedures - they're already here....
325
326
327// Igor Extensions, platform-specific
328        if(isMac)
329                MoveFolder/Z=1 homePathStr+"NCNR_Extensions:Mac_XOP" as extPathStr+"NCNR_Extensions"
330        else
331                MoveFolder/Z=1 homePathStr+"NCNR_Extensions:Win_XOP" as extPathStr+"NCNR_Extensions"
332        endif
333        Print "*******Move folder NCNR_Extensions:xxx_XOP into User Special Folder, NO overwrite: "+IsMoveOK(V_flag)
334//     
335// not needed now
336//      if(isMac)
337//              CreateAliasShortcut/O/P=UPPath "NCNR_Extensions:Mac_XOP" as igorPathStr+"Igor Extensions:NCNR_Extensions"
338//      else
339//              CreateAliasShortcut/O/P=UPPath "NCNR_Extensions:Win_XOP" as igorPathStr+"Igor Extensions:NCNR_Extensions"
340//      endif
341//      Print "Creating shortcut for XOP into Igor Extensions: "+IsMoveOK(V_flag)
342       
343
344// put shortcuts to the template in the "top" folder
345//
346        NewPath/O/Q UtilPath, homePathStr+"NCNR_SANS_Utilities:"
347        strFileList = IndexedFile(UtilPath,-1,".pxt")   
348        for (i=0; i<itemsInList(strFileList); i+=1)
349                tmpStr = StringFromList(i,strFileList)
350//              isThere = CheckForMatch(tmpStr,IHFolders)
351//              if(isThere)
352//                      Print "Move "+ tmpStr
353//                      MoveFolder/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
354                        CreateAliasShortcut/O/P=UtilPath tmpStr as homePathStr +tmpStr
355                        Print "Creating shortcut for "+tmpStr+" into top level: "+IsMoveOK(V_flag)
356//              endif
357        endfor
358
359
360// installation is done, quit to start fresh
361        DoAlert 1, "Quit Igor to complete installation.\rQuit now? "
362        if (V_Flag==1)
363                execute "Quit /Y"
364        endif
365       
366        return 1
367End
368
369// return (1) if str is an entry in tw
370// must be an exact match, with or without ".lnk" extension
371//
372Function CheckForMatch(str,tw)
373        String str
374        Wave/T tw
375       
376        Variable num=numpnts(tw),ii=0
377       
378        do
379                if(cmpstr(str,tw[ii])==0 || cmpstr(str,tw[ii]+".lnk")==0)
380                        return (1)
381                endif
382                ii+=1
383        while(ii<num)
384       
385        return(0)
386End
387
388
389Function InstallButtonProc(ba) : ButtonControl
390        STRUCT WMButtonAction &ba
391
392        switch( ba.eventCode )
393                case 2: // mouse up
394                        // click code here
395                        InstallNCNRMacros(0)
396                        break
397        endswitch
398
399        return 0
400End
401
402Function UpdateCheckButtonProc(ba) : ButtonControl
403        STRUCT WMButtonAction &ba
404
405        switch( ba.eventCode )
406                case 2: // mouse up
407                        // click code here
408                        Execute "CheckForLatestVersion()"
409                        break
410        endswitch
411
412        return 0
413End
414
415Function DiagnosticsProc(ba) : ButtonControl
416        STRUCT WMButtonAction &ba
417
418        switch( ba.eventCode )
419                case 2: // mouse up
420                        // click code here
421                        InstallDiagnostics()
422                        break
423        endswitch
424
425        return 0
426End
427
428Window InstallerPanel() : Panel
429        PauseUpdate; Silent 1           // building window...
430        NewPanel /W=(150,50,445,292)    /K=2
431        Button button0,pos={73,24},size={150,40},proc=InstallButtonProc,title="Install SANS Macros"
432        Button button0,fColor=(1,26214,0)
433        Button button0_1,pos={75,94},size={150,40},proc=UpdateCheckButtonProc,title="Check for Updates"
434        Button button0_1,fColor=(1,26221,39321)
435        Button button0_2,pos={75,164},size={150,40},proc=DiagnosticsProc,title="Print Diagnostics"
436        Button button0_2,fColor=(65535,0,0)
437EndMacro
438
439// generate a notebook with install diagnostics suitable for e-mail
440Function InstallDiagnostics()
441       
442        String nb="Install_Diagnostics_v6",textStr
443       
444        DoWindow/F $nb
445        if(V_flag==0)
446                NewNotebook/N=$nb/F=0 /W=(387,44,995,686) as nb
447        else
448                //clear contents
449                Notebook $nb selection={startOfFile, endOfFile}
450                Notebook $nb text="\r"
451        endif   
452       
453// what version, what platform
454        Notebook $nb text="**Install Diagnostics**\r\r"
455        Notebook $nb text="**Version / Platform**\r"
456        textStr =  IgorInfo(0)+"\r"
457        Notebook $nb text=textStr
458        textStr =  IgorInfo(2)+"\r"
459        Notebook $nb text=textStr
460// what is the currently installed version from the string
461        PathInfo Igor
462        String IgorPathStr = S_Path
463        String fileNameStr = IgorPathStr + "User Procedures:NCNR_User_Procedures:InstalledVersion.txt"
464        String installedStr
465        Variable refnum
466       
467        Open/R/Z refNum as fileNameStr
468        if(V_flag != 0)
469                //couldn't find the file
470                textstr = "I could not determine what version of the SANS Macros you are running."
471        else
472                FReadLine refNum, installedStr
473                Close refnum
474                textStr = installedStr
475        endif
476       
477        // check for permissions
478        Variable UP_err,IH_err,IE_err
479        UP_err = FolderPermissionCheck("User Procedures:")
480        IH_err = FolderPermissionCheck("Igor Help Files:")
481        IE_err = FolderPermissionCheck("Igor Extensions:")
482       
483        Print UP_err,IH_err,IE_err
484       
485        String alertStr=""
486        if(UP_err != 0)
487                alertStr += "User Procedures has no write permission. Error = "+num2Str(UP_err)+"\r"
488        else
489                alertStr += "User Procedures permission is OK.\r"
490        endif
491        if(IH_err != 0)
492                alertStr += "Igor Help Files has no write permission. Error = "+num2Str(IH_err)+"\r"
493        else
494                alertStr += "Igor Help Files permission is OK.\r"
495        endif
496        if(IE_err != 0)
497                alertStr += "Igor Extensions has no write permission. Error = "+num2Str(IE_err)+"\r"
498        else
499                alertStr += "Igor Extensions permission is OK.\r"
500        endif
501       
502        if(UP_err != 0 || IH_err != 0 || IE_err != 0)
503                alertStr += "You will need to install manually."
504        endif
505       
506        Notebook $nb text="\r\r**Folder Permissions**\r"
507        Notebook $nb text=AlertStr +"\r"
508       
509       
510        Notebook $nb text="\r\r**InstalledVersion.txt**\r"
511        Notebook $nb text=textStr +"\r"
512
513// get listings of everything in each folder
514        string strfileList=""
515
516// what is the listing of the Igor Extensions
517        Notebook $nb text="\r\r**Igor Extensions (files)**\r"
518        NewPath /Q/O ExPath, igorPathStr+"Igor Extensions:"
519       
520        //files
521        strFileList = IndexedFile(ExPath, -1, "????" )
522        textStr = ReplaceString(";", strFileList, "\r")
523        Notebook $nb text=textStr
524
525        //folders
526        Notebook $nb text="\r**Igor Extensions (folders)**\r"
527        strFileList = IndexedDir(ExPath, -1, 0 )
528        textStr = ReplaceString(";", strFileList, "\r")
529        Notebook $nb text=textStr+"\r"
530
531
532// what is the listing of Igor Help files
533        Notebook $nb text="\r\r**Igor Help (files)**\r"
534        NewPath /Q/O IHPath, igorPathStr+"Igor Help Files:"
535
536        //files
537        strFileList = IndexedFile(IHPath, -1, "????" )
538        textStr = ReplaceString(";", strFileList, "\r")
539        Notebook $nb text=textStr
540
541        //folders
542        Notebook $nb text="\r**Igor Help (folders)**\r"
543        strFileList = IndexedDir(IHPath, -1, 0 )
544        textStr = ReplaceString(";", strFileList, "\r")
545        Notebook $nb text=textStr+"\r"
546       
547       
548// what is the listing of the User Procedures
549        Notebook $nb text="\r\r**User Procedures (files)**\r"
550        NewPath /Q/O UPPath, igorPathStr+"User Procedures:"
551        //files
552        strFileList = IndexedFile(UPPath, -1, "????" )
553        textStr = ReplaceString(";", strFileList, "\r")
554        Notebook $nb text=textStr
555
556        //folders
557        Notebook $nb text="\r**User Procedures (folders)**\r"
558        strFileList = IndexedDir(UPPath, -1, 0 )
559        textStr = ReplaceString(";", strFileList, "\r")
560        Notebook $nb text=textStr+"\r"
561       
562// what is the listing of the Igor Procedures
563
564//  generating a path for this seems to be problematic - since it can't be killed , or found on another computer
565// that is (apparently) because if there is anything included from the IgP folder (and there is on even the default installation)
566// - then the path is "in use" and can't be killed...
567//
568        Notebook $nb text="\r\r**Igor Procedures (files)**\r"
569        NewPath /Q/O IgorProcPath, igorPathStr+"Igor Procedures:"
570
571        //files
572        strFileList = IndexedFile(IgorProcPath, -1, "????" )
573        textStr = ReplaceString(";", strFileList, "\r")
574        Notebook $nb text=textStr
575
576        //folders
577        Notebook $nb text="\r**Igor Procedures (folders)**\r"
578        strFileList = IndexedDir(IgorProcPath, -1, 0 )
579        textStr = ReplaceString(";", strFileList, "\r")
580        Notebook $nb text=textStr+"\r"
581//
582//
583        // then get a listing of the "home" directory. If files were not moved properly, they will still be here
584        Notebook $nb text="\r\r**Home (files)**\r"
585//      NewPath /Q/O IgorProcPath, igorPathStr+"Igor Procedures:"
586
587        //files
588        strFileList = IndexedFile(home, -1, "????" )
589        textStr = ReplaceString(";", strFileList, "\r")
590        Notebook $nb text=textStr
591
592        //folders
593        Notebook $nb text="\r**Home (folders)**\r"
594        strFileList = IndexedDir(home, -1, 0 )
595        textStr = ReplaceString(";", strFileList, "\r")
596        Notebook $nb text=textStr+"\r"
597       
598        //move to the beginning of the notebook
599        Notebook $nb selection={startOfFile, startOfFile}       
600        Notebook $nb text=""
601       
602        return(0)
603End
604
605Function AskUserToKillHelp()
606
607        //// clean up the Igor help files
608// first, kill any open help files
609// there are 5 of them
610        Variable numHelpFilesOpen=0
611//      do
612                numHelpFilesOpen = 0
613                // V_flag is set to zero if it's found, non-zero (unspecified value?) if it's not found
614                DisplayHelpTopic/Z "Beta SANS Tools"
615                if(V_flag==0)
616                        numHelpFilesOpen += 1
617                endif
618               
619                DisplayHelpTopic/Z "SANS Data Analysis Documentation"
620                if(V_flag==0)
621                        numHelpFilesOpen += 1
622                endif
623                               
624                DisplayHelpTopic/Z "SANS Model Function Documentation"
625                if(V_flag==0)
626                        numHelpFilesOpen += 1
627                endif
628                               
629                DisplayHelpTopic/Z "SANS Data Reduction Tutorial"
630                if(V_flag==0)
631                        numHelpFilesOpen += 1
632                endif
633                               
634                DisplayHelpTopic/Z "USANS Data Reduction"
635                if(V_flag==0)
636                        numHelpFilesOpen += 1
637                endif
638                       
639//              PauseForUser            // can't use this, it keeps you from interacting with anything....
640//      while(NumHelpFilesOpen != 0)
641        DoWindow HelpNotebook
642        if(V_flag)
643                DoWindow/K HelpNotebook
644        endif
645       
646        String helpStr = "Please kill the open Help Files by holding down the OPTION key (Macintosh) or ALT key (Windows) and then CLICKING on the close box of each help window."
647        helpStr += " Once you have finished, please close this window and install the SANS Macros."
648        if(NumHelpFilesOpen != 0)
649                NewNotebook/F=1/K=1/N=HelpNotebook /W=(5,44,547,380) as "Please close the open help files"
650                Notebook HelpNotebook,fsize=18,fstyle=1,showRuler=0,text=helpStr
651                return(0)
652        endif
653
654        return(0)
655End
656
657//check each of the three folders
658// folder string MUST have the trailing colon
659Function FolderPermissionCheck(folderStr)
660        String folderStr
661        Variable refnum
662        String str="delete me"
663       
664        String igorPathStr,resultStr=""
665        PathInfo Igor
666        igorPathStr = S_Path
667       
668        NewPath /Q/O tmpPath, igorPathStr+folderStr
669
670       
671        Open/Z/P=tmpPath refnum as "test.txt"
672        if(V_flag != 0)
673                return(V_flag)
674        else
675                FBinWrite refnum,str
676                Close refnum
677               
678//              Print "folder OK"
679                DeleteFile/Z/P=tmpPath  "test.txt"
680        endif
681       
682       
683        return(V_flag)
684end
685
686Function/S IsMoveOK(flag)
687        Variable flag
688       
689        String alertStr="There are old NCNR procedures and files present. You will need admin privileges to manually remove them before you can continue"
690        if(flag == 0)
691                return(" OK")
692        else
693                DoAlert 0,alertStr
694                return(" ERROR")
695        endif
696end
697
698// this will "force" an install, even if there are R/W errors
699Macro ForceInstall()
700
701        Execute "InstallNCNRMacros(1)"
702end
Note: See TracBrowser for help on using the repository browser.