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" |
---|
5 | // |
---|
6 | // compares to the installed version string, which is installed in UP:NCNR_UP |
---|
7 | // |
---|
8 | // |
---|
9 | // |
---|
10 | Proc CheckForLatestVersion() |
---|
11 | |
---|
12 | String url = "ftp://ftp.ncnr.nist.gov/pub/sans/kline/CurrentVersion.txt" |
---|
13 | String currentStr,installedStr,fileNameStr="",varStr="",str |
---|
14 | Variable refNum,upToDateVersion,runningVersion |
---|
15 | |
---|
16 | fileNameStr = SpecialDirPath("Packages", 0, 0, 0) |
---|
17 | fileNameStr += "CurrentVersion.txt" |
---|
18 | |
---|
19 | FTPDownload/O/Z url, fileNameStr |
---|
20 | |
---|
21 | Open/R refNum as fileNameStr |
---|
22 | FReadLine refNum, currentStr |
---|
23 | Close refnum |
---|
24 | |
---|
25 | Print "Current = ",CurrentStr |
---|
26 | // don't use the local strings anymore |
---|
27 | // setDataFolder root: |
---|
28 | // varStr=VariableList("*VERSION",";",6) |
---|
29 | // if(strlen(varStr)==0) |
---|
30 | // SetDataFolder root:Packages:NIST: |
---|
31 | // varStr=VariableList("*VERSION",";",6) |
---|
32 | // endif |
---|
33 | // if(strlen(varStr)==0) |
---|
34 | // Abort "Can't find the local version number" |
---|
35 | // Endif |
---|
36 | |
---|
37 | // find the installed version |
---|
38 | PathInfo Igor |
---|
39 | String IgorPathStr = S_Path |
---|
40 | fileNameStr = IgorPathStr + "User Procedures:NCNR_User_Procedures:InstalledVersion.txt" |
---|
41 | |
---|
42 | Open/R/Z refNum as fileNameStr |
---|
43 | if(V_flag != 0) |
---|
44 | //couldn't find the file, send user to web site to update |
---|
45 | sprintf str,"I could not determine what version of the SANS Macros you are running." |
---|
46 | str += " You need to go to the NCNR website for the latest version. Do you want to go there now?" |
---|
47 | DoAlert 1,str |
---|
48 | if(V_flag==1) |
---|
49 | BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html" |
---|
50 | endif |
---|
51 | //don't need to close if nothing was opened (/Z) |
---|
52 | else |
---|
53 | |
---|
54 | FReadLine refNum, installedStr |
---|
55 | Close refnum |
---|
56 | |
---|
57 | Print "Installed = ",installedStr |
---|
58 | |
---|
59 | runningVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), installedStr,"=",";") |
---|
60 | upToDateVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";") |
---|
61 | |
---|
62 | If(runningVersion != upToDateVersion) |
---|
63 | sprintf str,"You are running version %g and the latest version is %g.",runningVersion,upToDateVersion |
---|
64 | str += " You need to go to the NCNR website for the latest version. Do you want to go there now?" |
---|
65 | DoAlert 1,str |
---|
66 | if(V_flag==1) |
---|
67 | BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html" |
---|
68 | endif |
---|
69 | else |
---|
70 | DoAlert 0,"You are running the most up-to-date version = "+StringByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";") |
---|
71 | endif |
---|
72 | endif |
---|
73 | |
---|
74 | End |
---|