Automatically Updating Stacks

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
nicoloose
Posts: 88
Joined: Mon Sep 16, 2013 3:35 pm

Automatically Updating Stacks

Post by nicoloose » Tue Mar 04, 2014 3:22 pm

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!

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Automatically Updating Stacks

Post by BvG » Tue Mar 04, 2014 7:52 pm

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:

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
But as I said, that's only half the way towards what you want :(
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

nicoloose
Posts: 88
Joined: Mon Sep 16, 2013 3:35 pm

Re: Automatically Updating Stacks

Post by nicoloose » Wed Mar 05, 2014 7:44 am

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.

Klaus
Posts: 11061
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Automatically Updating Stacks

Post by Klaus » Wed Mar 05, 2014 1:05 pm

HI Nico,

you might want to take a look at this posting:
http://forums.runrev.com/phpBB2/viewtop ... 714#p79718

:D


Best

Klaus

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Automatically Updating Stacks

Post by BvG » Wed Mar 05, 2014 7:52 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”