Library stacks using handlers from one another
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Library stacks using handlers from one another
Hi all
I am working on splitting a large code, as discussed here:
https://forums.livecode.com/viewtopic.php?f=9&t=33461
into several library stacks. But some of the code is used in multiple areas of the current large script. I want to find the best way of implementing that.
As an example, suppose that i have a button that says "clean text", that carries out a large number of operations in a text field. It will call a library stack to clean spacing, then call another to color text. These libraries both need to refer to another library called, say, text scripts.
What is the right tactic to allow the libraries to have access to other libraries?
I am working on splitting a large code, as discussed here:
https://forums.livecode.com/viewtopic.php?f=9&t=33461
into several library stacks. But some of the code is used in multiple areas of the current large script. I want to find the best way of implementing that.
As an example, suppose that i have a button that says "clean text", that carries out a large number of operations in a text field. It will call a library stack to clean spacing, then call another to color text. These libraries both need to refer to another library called, say, text scripts.
What is the right tactic to allow the libraries to have access to other libraries?
Kaveh
Re: Library stacks using handlers from one another
I'm not sure my understanding is complete in this area, but doesn't "start using ..." ensure the stack (and therefore, its handlers/functions/etc) is placed in the message path?

Re: Library stacks using handlers from one another
Thanks Bogs. So suppose I have two stacks and each needs access to handlers in the other, do you think I can say "start using stack A" in the openstack of B and vice versa?
Kaveh
Re: Library stacks using handlers from one another
I have no idea, but why would you call it from a sub stack instead of calling them all from the main stack? When I said -
Of course, I could be completely off, again, I don't use them a lot.
I wasn't kidding. To make sure I'm being clear as I can be, I am responding to -
From what I get about library stacks, you just call them by putting 'start using [stack name]'. Me, I'd put that right into the preOpenStack for your main stack to ensure they are loaded and ready for use.kaveh1000 wrote: ↑Wed Dec 25, 2019 3:21 pmsplitting a large code, as discussed here:
https://forums.livecode.com/viewtopic.php?f=9&t=33461
into several library stacks
Of course, I could be completely off, again, I don't use them a lot.

Re: Library stacks using handlers from one another
Thank both. Attached is a diagram to show what I mean. I have a main stack that as you say opens the 3 Lib files and says "Start using..." for each Lib. But I want each lib to be able to access handlers and functions from there other Libs. So can I have an openstack in each of these Libs to "Start using" the other two Libs?
Kaveh
Re: Library stacks using handlers from one another
When you "start using xyz" then all open stacks can access its scripts, so no need to take further actions! 

Re: Library stacks using handlers from one another
You can also check whether you library stack name is in the stacksInUse and only start using if it's not there. I don't think it makes a difference if you try to "start using" a stack more than once but, just one of those tidy things.
Re: Library stacks using handlers from one another
Here is the BYU page on libraries, the picture shows you where a library sits in the message path and gives examples of the various posts in this thread.

Re: Library stacks using handlers from one another
Thanks Bogs. Actually the BYU pages are the best, and I did read them. What I was unsure of was whether each library could also access any other libraries that are open. It seems they can. I will keep working and come back if there are more questions.
Kaveh