Page 1 of 1

Best wa to Start using an external stack

Posted: Wed Jul 24, 2013 5:20 pm
by waprothero
I am storing component stacks and libraries in external stacks. I'm wondering what the best way to get these available? The code I use is below. The problem is that when I do the open command, then the stack is the default one and I have to then return to the calling stack. This works fine, but there are probably messages that are sent when I return and it could cause complications in the future.

Is this the best way to do this?

function checkLibStack theLibStackName
put the mainstack of this stack into theMainStack
put the name of this stack into callingStack
put the name of this card into callingCard
if not (stacksinuse contains theLibStackName) then
if not (the stacks contains theLibStackName) then
put getAFilePath("projLibraries/"&theLibStackName&".livecode") into targetStack
open invisible card 1 of stack targetStack
if the result <> "" then
answer "Problem opening lib stack; "&theLibStackName
end if
end if
start using stack theLibStackName
initLib(callingStack)
go to card callingCard of stack callingStack
return TRUE
else
return TRUE
end if
end checkLibStack

Re: Best wa to Start using an external stack

Posted: Wed Jul 24, 2013 5:58 pm
by FourthWorld
See "start using" in the Dictionary.

Re: Best wa to Start using an external stack

Posted: Wed Jul 24, 2013 6:06 pm
by dunbarx
Hi.

You do not have to go to or open a stack to start using it. One line does the trick:

start using stack "long name of stackToPutInUse"

Craig Newman

Re: Best wa to Start using an external stack

Posted: Wed Jul 24, 2013 6:07 pm
by dunbarx
Richard.

He did have a line to start using the stack. But he also opened and went there as well. The complaint was that the journey was onerous.

Craig

Re: Best wa to Start using an external stack

Posted: Wed Jul 24, 2013 6:19 pm
by FourthWorld
Good catch, Craig. The journey need not be onerous once you remove the extra steps. Reviewing the Dictionary entry for "start using" might have helped an understanding of how libraries work, but your clear instructions here certainly did.

Re: Best wa to Start using an external stack

Posted: Thu Jul 25, 2013 2:03 am
by waprothero
Thanks, folks! I hadn't known I needed to use "the long name of mystack"
That should make it much more straightforward and I don't risk getting un-needed messages passed around.