Page 1 of 1

Check for newer file/replace old

Posted: Tue May 13, 2014 10:16 pm
by DavJans
I've found lots of example to check for files, list them and so on, but nothing really specific enough unless I missed something.
my problem is that right now I have a stand alone app that I have stored on the server, as it gets bigger and bigger it takes longer to open it from our tablets. Another issue is that every time I want to update it I have to log into the server, manage open files, kick them out and then replace it.

What I would like to do is create a simple stack, call it launcher for example.

on openStack
check version of .exe at server
if the exe is the same
open local exe
else
copy newer exe from server replacing local exe
open local exe
end if
close stack
end openStack

Is this possible or is there a better way to do it?

Re: Check for newer file/replace old

Posted: Wed May 14, 2014 7:14 am
by AndyP
The usual way to do this is to have a text file on the server which holds the newest version number of the stack/app

and in this example a var currentVersion in the running stack that has the erm... current version e.g. 1.0

e.g. if the txt file on server contains 1.1 then the script below will check to see if the currentVersion is less than the text version, find that it is, download the file to the current stacks file location, unload thecurrent stack and load the new version.


on mouseUp
put url "http://mysite.com/version.txt" into latestVersion
if the currentVersion of this stack < latestVersion then
put the effective filename of this stack into stackPath
put url "http://mysite.com/newStack.livecode" into url ("binfile:" & stackPath)
revert
end if
end mouseUp

Re: Check for newer file/replace old

Posted: Sat Jul 12, 2014 4:12 pm
by gpearson
Here is how I am doing this on my application. My splash application calls a web service on the applications website that I use and tests the value of the returned value from the web service to the custom property of the application. If they do not match then the splash screen will:

If the custom property is greater than the web service result, do nothing as the user has a newer version.
If the custom property is lower than the web service result, then lets download new version, extract it and run it.
If the custom property is the same as the web service result, then run current version


This allows me to log in to the website CMS and update the value when a new version comes out, and upload the new version to the website. This saves me time as I do not have to ssh into the server, update a text file and sftp a new version to the website into a defined directory.


AndyP wrote:The usual way to do this is to have a text file on the server which holds the newest version number of the stack/app

and in this example a var currentVersion in the running stack that has the erm... current version e.g. 1.0

e.g. if the txt file on server contains 1.1 then the script below will check to see if the currentVersion is less than the text version, find that it is, download the file to the current stacks file location, unload thecurrent stack and load the new version.


on mouseUp
put url "http://mysite.com/version.txt" into latestVersion
if the currentVersion of this stack < latestVersion then
put the effective filename of this stack into stackPath
put url "http://mysite.com/newStack.livecode" into url ("binfile:" & stackPath)
revert
end if
end mouseUp