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

Last change on this file since 839 was 839, checked in by srkline, 11 years ago

Updating the installer to include the two new help files if they are present

More additions to the Real-Space Modeling help file

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