Updating running apps
Richard Gaskin
ambassador at fourthworld.com
Mon Mar 29 14:48:46 EDT 2010
Sarah Reichelt wrote:
> I have some apps that when checking for updates, then offer a "Install
> & Relaunch" option.
> This seems really cool to me, but I haven't worked out how to do it in
> my Rev apps.
> If I am only updating separate sub-stacks, then I can work it out, but
> if I want to update the actual application file what can I do?
>
> I can get the existing app to download the new version, but then what?
> Can a running app replace itself on disk?
> Then how to tell it to quit & re-launch?
>
> On a Mac, I guess I could spit out an AppleScript to quit the app,
> re-locate the downloaded app, then restart it but the apps I have
> don't seem to start an AppleScript when doing this.
>
> Any suggestions?
I started down that road a while back, and then I realized that what
made it seem cool and exotic is that almost no one else does it.
Most apps download, some also install, almost none can use the new build
without quitting the old one first.
With Rev, using an anchor window pattern (sometimes called the "splash
stack" for those who don't also update their splash screen) you can
download compressed copies of your stack files, decompress them and
overwrite the old ones, issue a revert command, and you have a new version.
Sounds good, but in my brief experiments down that road I quickly
realized the wide range of things that can go wrong attempting to update
components on-the-fly: to do it well you need to write a fair amount of
code to restore globals (and hope you're using the same ones), save and
restore window states and data states, etc. ad tedium. Too easy to get
your fingers caught in the fan blades if you forget something.
Requiring a quit-and-relaunch lets you have a clean initialization,
without replicating a more complex version of that initialization in vivo.
And you'll have no complaints about having to quit and relaunch from
your end-users, since they've probably never seen an app that does it
any other way.
Whether you attempt to update in vivo or go for the more common
quit-and-relaunch, managing components can be made simpler by using a
version file hosted somewhere with your app, with its URL stored in a
custom property.
If you do this sort of thing often, you may consider using the Rev
Interop specs for that - see the ECMI document Ken posted in the Files
section at:
<http://tech.groups.yahoo.com/group/revInterop/>
I don't know if Trevor uses the RIP properties outlined there in his
updater, but I see that he uses them elsewhere in things like the Data
Grid, and with the RIPEdit tool also available in that group I've been
adding them to all of my libraries as well for a variety of version
control and managements tasks.
--
Richard Gaskin
Fourth World
Rev training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
revJournal blog: http://revjournal.com/blog.irv
More information about the use-livecode
mailing list