On 2017-08-14 10:59, Richard Kaye wrote:
Having a great deal of respect for your VFP chops, is your loader something you can share, Dave? I'm always curious about the mechanics of these types of things.
--
rk
Here's a copy/paste from FabNet, called from my Main.prg:
PROCEDURE CheckForNewerVersion() LOCAL lcServerVersion as String, lcLocalVersion as String, lcLANFile as String, loData as _dataVersions OF .\progs_dataVersions.prg, ; loShell as _ShellExecute OF HOME()+"ffc\environ.vcx", loRec as Object, llUpdateLAN as Logical, llMissing as Logical, lcLANVersion as String LOCAL ARRAY laInfo[1] lcLocalVersion = _screen.cversion && SetVersion() lcLANFile = ReadINI("General","SetupFile",'') loShell = NEWOBJECT("_ShellExecute", "_environ.vcx")
*** mjb 09/18/2015 - updated for Admin user, plus grabbing EXE from cloud *** mjb 02/17/2016 - DEV NOTE: This needs work yet to grab latest installer from web database and put in lcLANFile location; will finish later IF NOT EMPTY(lcLANFile) THEN WAIT WINDOW NOWAIT "Checking master source for latest update..." loData = NEWOBJECT("_dataVersions",".\progs_dataVersions.prg") *** mjb 02/17/2016 - moved this next IF block outside the next IF block after that so as to get lcLANVersion for the 3rd IF block IF FILE(lcLANFile) THEN && see if LAN version is the cLatestVersion lcLANVersion = GetVersion(lcLANFile) CopyInstallerLocally(lcLANFile,ALLTRIM(lcLANVersion)) && mjb 05-11-16 llUpdateLAN = loData.ConvertVersionToNumber(lcLANVersion) <> loData.ConvertVersionToNumber(oUtils.oClient.cLatestVersion) ELSE && update LAN with latest from web database llMissing = .T. llUpdateLAN = .T. ENDIF *** mjb 02/17/2016 - added iNetwork = 1 to only run this IF block for MBSS Cloud clients IF oUtils.iNetwork = 1 AND loData.ConvertVersionToNumber(lcLocalVersion) < loData.ConvertVersionToNumber(oUtils.oClient.cLatestVersion) THEN && verify update exe's version is as expected *** mjb 12/28/2015 - added check to only run this for PRODUCTION run IF oUtils.oConnection.Descript = "Production" AND llUpdateLAN THEN *** mjb 12/18/2015 - for now, just alert them IF llMissing THEN MESSAGEBOX(oUtils.Get_Translation("Your network installation file appears to be missing. This is not critical; this just allows you to have your computers update from a common spot on your network rather than the internet. Contact MBSS if you need assistance."),16,oUtils.Get_Translation("Update file missing")) ELSE MESSAGEBOX(oUtils.Get_Translation("Your network installation file (" + ALLTRIM(lcLANFile) + ") appears to be outdated (version " + ALLTRIM(lcLANVersion) + "). Contact MBSS if you need assistance."),48,oUtils.Get_Translation("Update file out of date")) ENDIF && llMissing ENDIF && llUpdateLAN ENDIF && loData.ConvertVersionToNumber(lcLocalVersion) < loData.ConvertVersionToNumber(oUtils.oClient.cLatestVersion)
IF FILE(lcLANFile) THEN lcServerVersion = GetVersion(lcLANFile) IF NOT EMPTY(lcServerVersion) THEN IF lcServerVersion > lcLocalVersion THEN IF MESSAGEBOX(oUtils.Get_Translation("An update is available for this application (version") + " " + lcServerVersion + "). " + oUtils.Get_Translation("Do you want to upgrade?"),4+32+0,oUtils.Get_Translation("Upgrade available.")) = 6 THEN && launch setup from server and quit this app *** mjb 02/17/2016 - changed next line to lcLANFile instead of lcFile loShell.ShellExecute(FULLPATH(lcLANFile)) RELEASE loShell oUtils.Shutdown_System() && mjb 05-13-16 was QUIT ENDIF && msgbox = 6 ENDIF && lcServerVersion > lcLocalVersion ELSE SET STEP ON ENDIF && NOT EMPTY(lcServerVersion) ENDIF && FILE(lcLANFile) ENDIF && NOT EMPTY(lcLANFile) ENDPROC && CheckForNewerVersion()
FUNCTION GetVersion(tcFile as String) as String *** mjb 09/24/2015 - created to quickly check version # on files LOCAL ARRAY laInfo[1] LOCAL lcVersion as String, loException as Exception TRY lcVersion = '' IF FILE(tcFile) THEN AGETFILEVERSION(laInfo,tcFile) lcVersion = laInfo[4] ENDIF CATCH TO loException lcVersion = '' ENDTRY RETURN lcVersion ENDFUNC && GetVersion(tcFile as String) as String
from my data object: FUNCTION ConvertVersionToNumber(tcVersion) as Number LOCAL lnNumber as Number, liMajor as Integer, liMinor as Integer, liRevision as Integer, liMultiplier as Integer IF NOT EMPTY(tcVersion) THEN liMultiplier = 10000 liMajor = VAL(GETWORDNUM(tcVersion,1,".")) liMinor = VAL(GETWORDNUM(tcVersion,2,".")) liRevision = VAL(GETWORDNUM(tcVersion,3,".")) lnNumber = (liMajor * liMultiplier^2) + (liMinor * liMultiplier^1) + (liRevision * liMultiplier^0) && could have skipped liMultiplier^0 but kept for logical flow ELSE lnNumber = 0 ENDIF && NOT EMPTY(tcVersion) RETURN lnNumber ENDFUNC && ConvertVersionToNumber(tcVersion) as Number