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

Last change on this file since 1224 was 1224, checked in by srkline, 3 years ago

updating the installer to include the new VSANS help file - so that it can be opened/killed when re-installing the macros

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