To run a stack delivered from a server is easy in LiveCode - run this in the Message Box:
- Code: Select all
go url "http://fourthworld.net/revnet/devolution/4W_gzipper.livecode"
In fact, that particular stack is useful for this sort of thing, as it lets you drop any file onto it and it'll make a gzip-compressed copy.
If you compress your stacks with that before uploading them to your server, you can download them even faster:
- Code: Select all
put url "http://somecompressedstack.livecode.gz" into tData
put decompress(tData) into tStackData
throw "Invalid stack file data"
go stack tData
Whether you load a stack from your local disk or from the Web, LiveCode doesn't care, it'll run it just the same. The only difference is that the filename property of a download stack is empty, since it exists on the local machine only in memory.
Because it has no filename, it can't be saved back to the server, at least not with the "save stack" command. You can POST data to the server, and if you need to send a stack you can write a CGI to receive files and send stack files to it with POST. But for my projects I use the stacks only for UI and have data handled separately from a data store. When the stack loads its openStack command requests the data it displays from the server, and then calls the server's API to POST data back to it.
With most of the app coming from the server, all I need the standalone for is to provide the LC engine. The standalone's stack script contains just a few lines of code to download the main stack, or report an error to the user if the network is unavailable. That downloaded stack file takes care of everything else, downloading data and even other stacks files as needed in response to things the user does throughout the session.
In most respects, it's very much like working with local stacks, except that rather than loading them from disk I load them the web.
If this sort of thing is interesting (and frankly it's so useful for net-connected apps it's almost a shame not to use downloaded stacks for the UI), you can make a plugin to easily post new versions of your stack to your server. I prefer scp or rsync over FTP because they're secure. Your plugin can have a button named something like "Publish to Server", and it saves your stack file, makes a gzipped copy, and uploads that to your server with SCP. This way any time you want to deploy a bug fix or new feature, making it available for all your users is just one click away. I had the pleasure of using that in a meeting not long ago, where they were describing a bug in a conference call and I fixed it and uploaded it before our meeting was done - all they had to do was run the app again and they were using the latest version.
PS: to see a simple example of a downloaded stack in action, in your LC IDE see Development->Plugins->GoLiveNet (it'll be "GoRevNet" if using a version prior to 8.0). That plugin uses the "load" command to provide async download so it can display a progress bar, but the download is so short I don't really need it.