Start Using Stack Initialization Location

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
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Start Using Stack Initialization Location

Post by dcpbarrington » Fri Sep 20, 2013 10:09 pm

I have a LiveCode app that has a number of libraries that are initialized when the stack starts. I use the following code:

Code: Select all

on preOpenStack
  if "XMLControl" is not among the lines of the StacksInUse then
      if the environment = "development" then
         start using stack "../lib/saverXMLControl.livecode"
      else
         start using stack "saverXMLControl.livecode"
      end if
   end if
<for each stack that is needed>
end preOpenStack
This works great as long as it is placed in the preOpenStack handler, HOWEVER.

I have the application on a Mobile device and when the app starts it displays a BLACK screen until the stacks are started and then goes to the first card. The user doesn't know what is going on when the screen is black, so I created a Splash Card to be displayed while the application is initializing.

I moved the code from the preOpenStack to the openCard handler on the splash card and it fails. The application starts, but if I go into the Message Box, none of the stacks are started in the StacksInUse.

If I move the code back to the preOpenStack, everything works.

What is the problem. Shouldn't I be able to start a stack after the Main stack is Open?
I would appreciate any thoughts from the forum.
Thank you in advance.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Start Using Stack Initialization Location

Post by jmburnod » Sat Sep 21, 2013 12:26 pm

Hi dcpbarrington,

I never used a stack to save data in IOS but I think the stack path is no correct.
It seems you can modify file (or stack) if it is in the cache or documentd folder.

maeby specialfolderPath is your friend in this case

Best regards
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Start Using Stack Initialization Location

Post by Klaus » Mon Sep 23, 2013 6:58 pm

Yes, on mobile ALWAYS use "specialfolderpath" codes!

Code: Select all

...
    if the environment = "development" then

        ## If you are not 100% sure what the current DEFAULTFOLDER is 8) 
        ## you should not use relative pathnames with: ../xxx
         start using stack "../lib/saverXMLControl.livecode"
      else
        ## Presuming you added this stack via the "Copy files" TAB in the standalone builder:
         start using stack (specialfolderpath("engine") & "/saverXMLControl.livecode"
      end if
...
Best

Klaus

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Start Using Stack Initialization Location

Post by dcpbarrington » Mon Sep 23, 2013 11:19 pm

Sorry for the confusion. I'm using the specialFolderPath("engine") to initialize the defaultFolder

Code: Select all

   if the environment = "mobile" then
      set the defaultFolder to specialFolderPath("engine")
   else
      set the itemDelimiter to "/"
      get the fileName of this stack
      set the defaultFolder to item 1 to -2 of it
   end if
I've played around with the order that the external stacks are started and it seams to have resolved the issue.
Don't know why, because the stacks have blank handles for on preOpenStack and on openStack messages. Nothing in the stack should have run, but it now works.

Thanks for the advice.
dcpbarrington

Post Reply