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

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

Some changes to the installer files to look in new paths, not complete yet at all.

Added proper error handling for all 4 cases in the new 1D Arithmetic panel. Also fixed a typo that was always removing set 2 from the display when the result was calculated.

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