Best wa to Start using an external stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 38
- Joined: Tue Sep 20, 2011 5:01 pm
- Contact:
Best wa to Start using an external stack
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Best wa to Start using an external stack
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Best wa to Start using an external stack
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
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
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Best wa to Start using an external stack
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 38
- Joined: Tue Sep 20, 2011 5:01 pm
- Contact:
Re: Best wa to Start using an external stack
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.
That should make it much more straightforward and I don't risk getting un-needed messages passed around.
Bill Prothero