Best wa to Start using an external 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
waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Best wa to Start using an external stack

Post by waprothero » Wed Jul 24, 2013 5:20 pm

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
Bill Prothero

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Best wa to Start using an external stack

Post by FourthWorld » Wed Jul 24, 2013 5:58 pm

See "start using" in the Dictionary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Best wa to Start using an external stack

Post by dunbarx » Wed Jul 24, 2013 6:06 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: Best wa to Start using an external stack

Post by dunbarx » Wed Jul 24, 2013 6:07 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Best wa to Start using an external stack

Post by FourthWorld » Wed Jul 24, 2013 6:19 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Re: Best wa to Start using an external stack

Post by waprothero » Thu Jul 25, 2013 2:03 am

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.
Bill Prothero

Post Reply