Dear Livecoders,
I must say that I have scoured the internet the entire day to find a meaningful example on how one could go about this. I've seen numerous posts and questions but no posts are actually helpful to a beginner like me.
I need a function to check if there is an update to the mainstack when the user opens the "standalone" / "splash" screen. Obviously, there would be the new version of the livecode file on the server which the "updater" would have to open and check on a "version" field. It would also have to open the local livecode file to check the current version to ascertain if there is an update. How does one do this when the app is already open in memory.
Is there an example of how this works? It's such a sought after thing, I am surprised that Livecode has not created a tutorial.
Please help. Am done with trial and error because error is winning every time!
Automatically Updating Stacks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Automatically Updating Stacks
There's no tutorial because this is a weird problem, some parts are trivial, and others are extremely hard, and also dependant on which platform you use. For example, often you can't save a stack nilly willy, like on mobiles there's specific places you need to use, or windows application folders which might accept to save, but actually silently saved the file somewhere else instead.
The easiest way is to start with the splash stack approach, as detailed in this lesson:
http://lessons.runrev.com/s/lessons/m/4 ... pplication
Next, as you correctly said yourself, you need to store some sort of version number in the stack that you can save. However, I suggest not to read the version from a stack online, but instead store a text file online with your version number. That way you can easily check it, within an url. If the number is larger then the current one, you can download the proper stack, and then overwrite the one you have locally. To make sure the proper stack is immediately loaded, you can then "revert" the stack, which will load the newly overwritten stack from the hard disk. For example:
But as I said, that's only half the way towards what you want 
The easiest way is to start with the splash stack approach, as detailed in this lesson:
http://lessons.runrev.com/s/lessons/m/4 ... pplication
Next, as you correctly said yourself, you need to store some sort of version number in the stack that you can save. However, I suggest not to read the version from a stack online, but instead store a text file online with your version number. That way you can easily check it, within an url. If the number is larger then the current one, you can download the proper stack, and then overwrite the one you have locally. To make sure the proper stack is immediately loaded, you can then "revert" the stack, which will load the newly overwritten stack from the hard disk. For example:
Code: Select all
on mouseUp
put url "http://thisisanexampleurl.fake/savedVersion.txt" into theVersion
if the currentVersion of this stack < theVersion then
put the effective filename of this stack into thePath
put url "http://thisisanexampleurl.fake/newStack.livecode" into url ("binfile:" & thePath)
revert
end if
end mouseUp

Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: Automatically Updating Stacks
Thank you...
So in other words, in the "launcher" stack, all version checks should be done with text files prior to opening any stack? It would work but isn't fool proof method of versioning. For this particular application, we use Mac and PC. Each user has a client which connects to a mysql db on the server. Updates are constant as new functions are added and bugs are fixed. We do not use mobile apps at all.
There is a sample stack http://www2.altuit.com/webs/altuit2/Run ... /main6.rev which demonstrates version checking by opening the stack which may be useful to other people that are looking for a similar fix.
So in other words, in the "launcher" stack, all version checks should be done with text files prior to opening any stack? It would work but isn't fool proof method of versioning. For this particular application, we use Mac and PC. Each user has a client which connects to a mysql db on the server. Updates are constant as new functions are added and bugs are fixed. We do not use mobile apps at all.
There is a sample stack http://www2.altuit.com/webs/altuit2/Run ... /main6.rev which demonstrates version checking by opening the stack which may be useful to other people that are looking for a similar fix.
Re: Automatically Updating Stacks
HI Nico,
you might want to take a look at this posting:
http://forums.runrev.com/phpBB2/viewtop ... 714#p79718
Best
Klaus
you might want to take a look at this posting:
http://forums.runrev.com/phpBB2/viewtop ... 714#p79718

Best
Klaus
Re: Automatically Updating Stacks
Just for clarity, I'm not saying you must use text files. What I meant is that it's easier then finding a way to check version information that is stored within a stack on a webserver. If you have a database online, it's probably easiest to store your version information within the database, I guess?
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode