Design best practises - libraries, sub-stacks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Design best practises - libraries, sub-stacks
LiveCoders,
Now that my try-outs with initial applications is advancing a little bit, I'm beginning to wonder about a couple of design questions and perhaps others have similar questions too?
Where would I put commands/functions/handlers that are common to a number of cards? In the stack script? I suppose these are the stack's "private libraries"
How about "libraries" that I want to share between different applications?
How and why would I use sub-stacks? Can the top stack access sub-stack functions and vice versa?
Now that my try-outs with initial applications is advancing a little bit, I'm beginning to wonder about a couple of design questions and perhaps others have similar questions too?
Where would I put commands/functions/handlers that are common to a number of cards? In the stack script? I suppose these are the stack's "private libraries"
How about "libraries" that I want to share between different applications?
How and why would I use sub-stacks? Can the top stack access sub-stack functions and vice versa?
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
-
- Posts: 32
- Joined: Sun Jun 22, 2014 2:37 am
Re: Design best practises - libraries, sub-stacks
Yeah, I had the same questions. To me, it is kind of funky since I have been a programmer in other, more structured, languages. In any case, check out this thread:
http://forums.livecode.com/viewtopic.php?f=7&t=21289
You may find it helpful. Jack
http://forums.livecode.com/viewtopic.php?f=7&t=21289
You may find it helpful. Jack
Re: Design best practises - libraries, sub-stacks
hi Tukcedo,
Your question works in my head for long time. What is the BEST way to do that.
I think you can have a look to "start using", "insert script" in the LC dictionary.
You can even import a text file like script and insert it into back or front
Substack access to main stack function and command but not inversed
Best regards
Jean-Marc
Your question works in my head for long time. What is the BEST way to do that.
Yes, you can put them in the stack script but LiveCode offers many capacities.Where would I put commands/functions/handlers that are common to a number of cards? In the stack script?
I think you can have a look to "start using", "insert script" in the LC dictionary.
You can even import a text file like script and insert it into back or front
No,Can the top stack access sub-stack functions and vice versa?
Substack access to main stack function and command but not inversed
Best regards
Jean-Marc
https://alternatic.ch
Re: Design best practises - libraries, sub-stacks
Thanks for that reference Jack, that seems to answer my questions!
Coming from C and Perl, I really have to get used to the stack concept, but we're getting there slowly
Coming from C and Perl, I really have to get used to the stack concept, but we're getting there slowly

Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Re: Design best practises - libraries, sub-stacks
A MUST READ (and understand) in this respect is the LC message hierarchie,
check this great article: http://www.fourthworld.com/embassy/arti ... _path.html
check this great article: http://www.fourthworld.com/embassy/arti ... _path.html
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Design best practises - libraries, sub-stacks
I really like how in Richard's diagrams the messages get sent down the message path, as opposed to up as it is visualized in the official docs. For me, it was much easier to figure out what was going on by imagining that all my controls are on the "surface" of the stack, and as messages are sent, they fall down through the message path until/if they are "caught" by an object/card/stack script. This is obviously a simplified explanation, but I have always preferred the top down representation.
--Sefro
--Sefro
Re: Design best practises - libraries, sub-stacks
Got a couple more design-related quessies which I've been playing with for a few days.
Firstly, what I'd like to do is go to a certain card and pass that card 1 or more variables. I've read up on send and dispatch but I'm not sure whether this actually opens the card. And if it does, how do I access that variable's value?
The other thing I've been trying to work out is how to structure a list of data with a button in one of the fields that jumps to a card with an argument as in the 1st question. Is there a simpler solution than the datagrid/form object (possibly way beyond my level of LC knowledge)?
Thanks for your advice!
Mich.
Firstly, what I'd like to do is go to a certain card and pass that card 1 or more variables. I've read up on send and dispatch but I'm not sure whether this actually opens the card. And if it does, how do I access that variable's value?
The other thing I've been trying to work out is how to structure a list of data with a button in one of the fields that jumps to a card with an argument as in the 1st question. Is there a simpler solution than the datagrid/form object (possibly way beyond my level of LC knowledge)?
Thanks for your advice!
Mich.
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Re: Design best practises - libraries, sub-stacks
Hi Mich,
Set some cps for the card like:
...
set the cValue1 of cd "your targetcard here..." to 42
set the cValue2 of cd "your targetcard here..." to "What is the ultimate answer?"
## of course you can use you own names for the custom props!
go cd "your targetcard here..."
...
Then in the script of cd "your targetcard here...":
on opencard
put the cValue1 of me into tValue1
put the cValue2 of me into tValue2
ask tValue2 with tValue1
## Just an example...
...
Hint: Unlike variables, custom properties will get saved with the stack!
So maybe you need to initialize them when the stack opens.
Best
Klaus
not sure I understand, but you can use custom properties for this!Tukcedo wrote:Firstly, what I'd like to do is go to a certain card and pass that card 1 or more variables. I've read up on send and dispatch but I'm not sure whether this actually opens the card. And if it does, how do I access that variable's value?
Set some cps for the card like:
...
set the cValue1 of cd "your targetcard here..." to 42
set the cValue2 of cd "your targetcard here..." to "What is the ultimate answer?"
## of course you can use you own names for the custom props!

go cd "your targetcard here..."
...
Then in the script of cd "your targetcard here...":
on opencard
put the cValue1 of me into tValue1
put the cValue2 of me into tValue2
ask tValue2 with tValue1
## Just an example...
...
Hint: Unlike variables, custom properties will get saved with the stack!
So maybe you need to initialize them when the stack opens.
Sorry, dont get this really!?Tukcedo wrote:The other thing I've been trying to work out is how to structure a list of data with a button in one of the fields that jumps to a card with an argument as in the 1st question. Is there a simpler solution than the datagrid/form object (possibly way beyond my level of LC knowledge)?

Best
Klaus
Re: Design best practises - libraries, sub-stacks
Mitch.
Know that the "natural" path of the message hierarchy is "up", regardless of which way you perceive that. A stack is "higher" than a card, which is higher than a control.
But LC allows any message to be sent in any direction. I think you alluded to the "dispatch" command. Check out also my favorite, "send" which has different features. Both of these permit one to shoot a message up, down or sideways. So if a stack handler can send a message to a button on another stack or substack, then of course a stack handler can send a message to a substack directly.
Craig Newman
Know that the "natural" path of the message hierarchy is "up", regardless of which way you perceive that. A stack is "higher" than a card, which is higher than a control.
But LC allows any message to be sent in any direction. I think you alluded to the "dispatch" command. Check out also my favorite, "send" which has different features. Both of these permit one to shoot a message up, down or sideways. So if a stack handler can send a message to a button on another stack or substack, then of course a stack handler can send a message to a substack directly.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Design best practises - libraries, sub-stacks
Mitch, it's time for a revelation, without which you may not fully understand what you've stepped into. This is an ancient war fought by two tribes, each passionate in their beliefs but bitterly opposed on the issue of hierarchy diagramming.dunbarx wrote:Mitch.
Know that the "natural" path of the message hierarchy is "up", regardless of which way you perceive that. A stack is "higher" than a card, which is higher than a control.
Both sides acknowledge that messages flow from one place to another, and do so in a fixed, reliable way. But where they disagree, sometimes to the point of fisticuffs after too many pints, is how to illustrate this message passing in a diagram.
The Bottom-Upper tribe (sometimes called Sky Worshipers) portray the message path as moving from the ground up, with the sky being the ultimate destination, where the engine resides in the heavens.
The Top-Downers (also called Earth Worshipers) depict the message path as beginning in the sky, and descending downward to an engine that resides in the Earth.
Brave souls each, yet firm in their own beliefs.
Then there is a splinter group, which some call the Rationalists, who prefer to describe the message path as moving from front to back. Some say this tribe earned their name because their portrayal of the message path merely reflects what we see when looking at a screen. But others say it's because they're rationalizing their way out of having to pick a side, suggesting a view that may sound well and good in conversation but is difficult to render in two dimensions, thus ultimately achieving nothing.
I was born among the Bottom-Uppers, and for many ages accepted their diagrams without question. But later I was seduced by the Top-Downers into believing their way better, a view of the message path being as natural as gravity, with messages falling accordingly.
Which side will you choose among these timeless tribes? And are you prepared to devote sufficient blogging time to defending your beliefs? Anything less may be heresy!

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: Design best practises - libraries, sub-stacks
Cor blimey! Well, for the time being I will just take in the arguments from both sides if you don't mindFourthWorld wrote: Which side will you choose among these timeless tribes? And are you prepared to devote sufficient blogging time to defending your beliefs? Anything less may be heresy!

That answers the question I think Klaus, vielen Dank!Klaus wrote: ...
set the cValue1 of cd "your targetcard here..." to 42
set the cValue2 of cd "your targetcard here..." to "What is the ultimate answer?"
## of course you can use you own names for the custom props!![]()
go cd "your targetcard here..."
...
Then in the script of cd "your targetcard here...":
on opencard
put the cValue1 of me into tValue1
put the cValue2 of me into tValue2
ask tValue2 with tValue1
## Just an example...
...
Can's say I blame youKlaus wrote:Sorry, dont get this really!?Tukcedo wrote:The other thing I've been trying to work out is how to structure a list of data with a button in one of the fields that jumps to a card with an argument as in the 1st question. Is there a simpler solution than the datagrid/form object (possibly way beyond my level of LC knowledge)?

Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Re: Design best practises - libraries, sub-stacks
Richard.
Gravity is an illusion.
I am reminded of the scene in Monty Python's "Life of Brian", where Brian is running from his ever growing band of followers, and loses a sandal. Half that crowd deemed the sandal sacred, a sign from Brian to follow it. There was another, similar artifact, that was embraced by the other half. I forget what that was, but the point is that both were comically arbitrary.
That said, I will proclaim jihad on anyone who does not think that controls are on the bottom of a hierarchal pyramid, with the engine at the top.
Craig
Gravity is an illusion.
I am reminded of the scene in Monty Python's "Life of Brian", where Brian is running from his ever growing band of followers, and loses a sandal. Half that crowd deemed the sandal sacred, a sign from Brian to follow it. There was another, similar artifact, that was embraced by the other half. I forget what that was, but the point is that both were comically arbitrary.
That said, I will proclaim jihad on anyone who does not think that controls are on the bottom of a hierarchal pyramid, with the engine at the top.
Craig
Re: Design best practises - libraries, sub-stacks
I avoid the whole issue by referring to messages as "before" and "after". My path is horizontal.
For the question about the list, do you really need a button? A list field can capture the selection and call a card handler that processes it. That handler can set up all the parameters and then go to a card. I do this frequently but I'm not sure if it fits your situation.

For the question about the list, do you really need a button? A list field can capture the selection and call a card handler that processes it. That handler can set up all the parameters and then go to a card. I do this frequently but I'm not sure if it fits your situation.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Design best practises - libraries, sub-stacks
Not in my topic you're not!dunbarx wrote: That said, I will proclaim jihad on anyone who does not think that controls are on the bottom of a hierarchal pyramid, with the engine at the top.
Craig


Sensible move! Think I'll join the horizontal lot then. Well in about an hour or so anywayjacque wrote:I avoid the whole issue by referring to messages as "before" and "after".

Interesting thought. How would the user make his choice though? I can see the use of text fields catching and handling events, but how would the user make a choice from the list?jacque wrote:For the question about the list, do you really need a button? A list field can capture the selection and call a card handler that processes it. That handler can set up all the parameters and then go to a card. I do this frequently but I'm not sure if it fits your situation.
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl
Re: Design best practises - libraries, sub-stacks
Hi again from the Levant.
Make a new list field. It comes with a few lines already filled, so simply place this into its script:
I bet you can see the possibilities...
Craig
Make a new list field. It comes with a few lines already filled, so simply place this into its script:
Code: Select all
on mouseup
put word 2 of the selectedLine && the selectedText
end mouseup
Craig