#pragma rtGlobals=1 // Use modern global access method. #pragma IgorVersion=6.1 // goes to our ftp site and downloads "CurrentVersion.txt" // // compares to the installed version string, which is installed in UP:NCNR_UP // // // Proc CheckForLatestVersion() String url = "ftp://ftp.ncnr.nist.gov/pub/sans/kline/CurrentVersion.txt" String currentStr,installedStr,fileNameStr="",varStr="",str Variable refNum,upToDateVersion,runningVersion fileNameStr = SpecialDirPath("Packages", 0, 0, 0) fileNameStr += "CurrentVersion.txt" FTPDownload/O/Z url, fileNameStr Open/R refNum as fileNameStr FReadLine refNum, currentStr Close refnum Print "Current = ",CurrentStr // don't use the local strings anymore // setDataFolder root: // varStr=VariableList("*VERSION",";",6) // if(strlen(varStr)==0) // SetDataFolder root:Packages:NIST: // varStr=VariableList("*VERSION",";",6) // endif // if(strlen(varStr)==0) // Abort "Can't find the local version number" // Endif // find the installed version PathInfo Igor String IgorPathStr = S_Path fileNameStr = IgorPathStr + "User Procedures:NCNR_User_Procedures:InstalledVersion.txt" Open/R/Z refNum as fileNameStr if(V_flag != 0) //couldn't find the file, send user to web site to update sprintf str,"I could not determine what version of the SANS Macros you are running." str += " You need to go to the NCNR website for the latest version. Do you want to go there now?" DoAlert 1,str if(V_flag==1) BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html" endif //don't need to close if nothing was opened (/Z) else FReadLine refNum, installedStr Close refnum Print "Installed = ",installedStr runningVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), installedStr,"=",";") upToDateVersion = NumberByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";") If(runningVersion != upToDateVersion) sprintf str,"You are running version %g and the latest version is %g.",runningVersion,upToDateVersion str += " You need to go to the NCNR website for the latest version. Do you want to go there now?" DoAlert 1,str if(V_flag==1) BrowseURL "http://www.ncnr.nist.gov/programs/sans/data/red_anal.html" endif else DoAlert 0,"You are running the most up-to-date version = "+StringByKey(StringFromList(0,"PACKAGE_VERSION"), currentStr,"=",";") endif endif End