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

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

Tweaks for the installer.

File size: 2.9 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4// goes to our ftp site and downloads "CurrentVersion.txt", puts this in "Packages"
5// in the WM preferences folder. I can write to it here, and it won't mess with any install
6//
7// compares to the installed version string, which is installed in UP:NCNR_UP
8//
9//
10//
11Proc CheckForLatestVersion()
12
13        String url = "ftp://ftp.ncnr.nist.gov/pub/sans/kline/CurrentVersion.txt"
14        String currentStr,installedStr,fileNameStr="",varStr="",str
15        Variable refNum,upToDateVersion,runningVersion
16       
17        fileNameStr = SpecialDirPath("Packages", 0, 0, 0)
18        fileNameStr += "CurrentVersion.txt"
19
20        FTPDownload/O/Z url, fileNameStr
21
22        Open/R refNum as fileNameStr
23        FReadLine refNum, currentStr
24        Close refnum
25       
26        Print "Current = ",CurrentStr
27        // don't use the local strings anymore 
28//      setDataFolder root:
29//      varStr=VariableList("*VERSION",";",6)
30//      if(strlen(varStr)==0)
31//              SetDataFolder root:Packages:NIST:
32//              varStr=VariableList("*VERSION",";",6)
33//      endif
34//      if(strlen(varStr)==0)
35//              Abort "Can't find the local version number"
36//      Endif
37       
38        // find the installed version
39        PathInfo Igor
40        String IgorPathStr = S_Path
41        fileNameStr = IgorPathStr + "User Procedures:NCNR_User_Procedures:InstalledVersion.txt"
42       
43        // the Igor 6.1 User Procedure Path, same sub-folders as in Igor App Folder
44        String userPathStr=RemoveEnding(SpecialDirPath("Igor Pro User Files",0,0,0),":")+":"
45       
46        // try the UP folder in the Igor Pro folder (older installations)
47        Open/R/Z refNum as fileNameStr
48        if(V_flag != 0)
49                //then try the special user directory (for 6.1+ installations)
50                Open/R/Z refNum as userPathStr
51                if(V_flag != 0)
52                        //couldn't find the file, send user to web site to update
53                        sprintf str,"I could not determine what version of the SANS Macros you are running."
54                        str += " You need to go to the NCNR website for the latest version. Do you want to go there now?"
55                        DoAlert 1,str
56                        if(V_flag==1)
57                                BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html"
58                        endif
59                        //don't need to close if nothing was opened (/Z)
60                       
61                        return          //couldn't find either file, nothing opened, exit
62                endif
63        endif
64       
65        // the file was opened, check the version
66        FReadLine refNum, installedStr
67        Close refnum
68       
69        Print "Installed = ",installedStr       
70       
71        runningVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), installedStr,"=",";")
72        upToDateVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";")
73       
74        If(runningVersion != upToDateVersion)
75                sprintf str,"You are running version %g and the latest version is %g.",runningVersion,upToDateVersion
76                str += " You need to go to the NCNR website for the latest version. Do you want to go there now?"
77                DoAlert 1,str
78                if(V_flag==1)
79                        BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html"
80                endif
81        else
82                DoAlert 0,"You are running the most up-to-date version = "+StringByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";")
83        endif
84       
85        return
86End
Note: See TracBrowser for help on using the repository browser.