loading another stack from splash

Sivakatirswami katir at hindu.org
Thu Sep 30 18:22:57 EDT 2010


  On 9/28/10 5:11 PM, Mark Smith wrote:
> Also, it would be real nice not to have to "hard code" the path in case I
> want to change its location. Having to manage two stacks instead of one does
> seems like an added burden.
>
> Stumped. Any help appreciated
>
> -- Mark
We meaning many of us here... do this all the time.
I love keeping stacks inside the OSX application bundle,
  you can develop them from inside there and ship as as single binary..

There are two common approaches These scripts may help

on loadFromDisk
     -- Setting the default folder.
     set itemdel to "/"
     set the defaultfolder to item 1 to -2 of the effective filename of 
this stack

     -- Check for application
     if there is not a file "MyNoteBook.rev" then
         if checkNet() then
             checkNetworkAndDownload #If you don't have it locally then 
get it from the web server
             exit loadFromDisk
         else
             answer error "Please connect to the internet to install 
this application"
             exit loadFromDisk
         end if
     end if

     go stack url "binfile:MyNoteBook.rev"
     hide  stack "MySplashEngine.rev"
end loadFromDisk

---------

on preopenstack
   go stack url (getPath("MyNoteBook.rev")
end preopenstack

function getPath tStack
     set the itemdel to "/"
     put the effective filename of this stack into tPath
     put tStack into item -1 of tPath
     return tPath
end getPath

By separating the function you have the interesting option of offering 
the user the option to open any number stacks you might bundle into the 
same folder:

On the splash screen you can have a pull down menu like this

on mousedown
    set the defaultfolder to item 1 to -2 of the effective filename of 
this stack
    put the files into tFiles
    filter tFiles with ("*.livecode")
    put tFiles into me
end mousedown

on menuPick pStack
     go stack url (getPath(pStack))
     hide this stack # hide the splash screen now...
end menupick

Now you can put what ever stacks you like into that folder.

Don't forget to include quit handlers in all the stacks so that you 
don't leave a hung process Hidden splash screen still running.

HTH

aloha





Mark assuming that you will always put the data stacks in the same 
folder as the splash-engine stack






More information about the use-livecode mailing list