Turning a Mainstack into a Substack for another Stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Turning a Mainstack into a Substack for another Stack

Post by deeverd » Tue Nov 06, 2007 5:23 pm

Hello Everyone,

I'm just getting ready to create my first little standalone, and just recently learned about splash screen.

In this case, I already made the main part of the program as a mainstack, and now I've created a splash screen as a separate mainstack.

My question is no doubt a very basic one, but how do I turn the main part of the program into a substack and then attach it as a substack to my splash screen stack?

Thanks as always, deeverd

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Tue Nov 06, 2007 6:46 pm

Hi,

the main benefit of a splash screen approach is, that you do not need to make your main application a substack. This will allow you to save the application stack if you want to do that and has some other benefits besides that (think of automated updates) All you will need to do is make your splash screen load the other stack with a single command

go stack "path/to/stack"

all messages that are not the startUp message will be sent to your stack. Most of the time you will want to make your splash screen install your main application to a place where you can find it easiely and in a location you know you should be able to write to. Take a look at specialfolderpath in the dictionary and visit Ken Rays site

http://www.sonsothunder.com/devres/revo ... ile010.htm

If you are already familiar with custom properties you can write a suckUp / spit out script that will allow you to make your main application stack a custom property of your splash screen that you then can write back to the location you chose on first launch of your application on a users machine.

If you have any questions regarding the process please ask.

All the best,

Malte

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Post by deeverd » Tue Nov 06, 2007 11:10 pm

Thank you Malte. The "Tips and Tricks" section at the Sons of Thunder site is a great resource. I'm glad you gave me a link to it.

I still have some confusion:
go stack "path/to/stack"
How does a standalone path work? In other words, while I'm building a stack, I know I have to give the program precise instructions on where to find the .rev substack file on my computer, but how does one tell the splash screen how to find the main application when they are bundled together in a standalone application on software that is being installed on somebody else's computer? Where do you tell it to look?

Also...
If you are already familiar with custom properties you can write a suckUp / spit out script that will allow you to make your main application stack a custom property of your splash screen that you then can write back to the location you chose on first launch of your application on a users machine.
The custom properties that you are talking about is not something I understand at this point in time, but from what you are saying, I can see that it is vital that I learn to understand it. I think this was mentioned in the Dan Shafer book in the last chapter or thereabouts, so I'll dust it off and refer to it right away, as well as look up custom properties in the Rev 2.7 documentation.

All the best, deeverd

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sat Nov 10, 2007 8:23 pm

Hi deeverd,

please excuse the late reply. I am pretty much on the road these days doing consultancy.

As for your question for the standalone path (please forgive me that I was not precise enough in my previous post):

I would make the splash screen (the executable) a basic installer. So your splash screen would always know where it has put the components it needs. Think of a preference file:

Code: Select all

on openPrefs
    --example
    -- Win specialfolderpath(26)/myApp/myApp.dat
    -- Mac specialfolderpath("preferences")/myApp/myApp.dat
    try
        global gMyPrefsPath
        local specialFolder,tPrefs,tTopStack
        put the topstack into tTopStack
        switch the platform
            case "MacOS"
                put specialfolderpath("preferences") into specialFolder
                break
            case "Win32"
                if word 1 of the systemversion = "NT" then
                    -- Windows NT,2000,XP and Vista
                    put specialfolderpath(26) into specialFolder
                else
                    -- Win 95,98 and ME
                    put specialfolderpath("system") into specialFolder
                end if
                if "U3" is in the globals then
                    -- Run from U3 USB-Stick
                    put $U3_APP_DATA_PATH into specialFolder
                end if
                break
            default
                -- All nixes
                put $Home into specialFolder
                break
        end SWITCH
        if there is not a folder (specialFolder & "/myApp") then create folder (specialFolder & "/myApp")
        if there is no stack (specialFolder & "/myApp/myApp.dat") then
            lock messages
            create invisible stack "myApp.dat"
            save stack "myApp.dat" as (specialFolder & "/myApp/myApp.dat")
            unlock messages
        else
            open invisible stack (specialFolder & "/myApp/myApp.dat")
        end if
        set the defaultstack to tTopStack
    catch theerror
        return "error: "&theError
    end TRY
end openPrefs
Same thing holds true for other components. Look where you want to write them (Application support folder can make sense for example on MAc system) and save your components there. Kens site will give you the correct folder paths. You can make the Splash screen carry stack files as custom properties that you then can write to the end users disk if they are not present, or if they are present load from the specified location.

Hope that helps a bit.

Malte

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Wow and Thanks

Post by deeverd » Mon Nov 12, 2007 9:40 pm

Hello Malte,

Yes, thank you very much, because the information above is extremely helpful and I'm finally starting to understand the whole standalone concept. No problem with your late reply, since often it's a week or more before I can get back on the forum due to work and university and home demands.

Just in case anyone even newer at programming than me (hard to imagine) is following this thread concerning standalone program information, I thought I'd just mention that I kept experimenting until I found out how to turn any mainstack into a substack for any other mainstack. What I found was that all I had to do was to open up a stack in Revolution Media or Studio, go to the application browser and then right click (I'm using Windows XP) on the mainstack symbol that I want to convert to a substack. By going to the Properties editor, specifically to the first "basic" page, I found that there is a button in there that allows me to scroll and find the name of the stack that I want to attach it to. Actually, it's very easy.

I also found out that a simple standalone compiles very effortlessly with Studio by merely pressing the second "standalone" button under the file menu. Granted, I know there's a lot more to it to make it a stack that can be automatically updated or that includes databases and unusal fonts, but so far so good anyway.

Now, I'm looking forward to applying Malte's excellent advice and making my programs much more professional.
Cheers, deeverd

Post Reply