Message hierarchy when external stack are used
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Message hierarchy when external stack are used
I have several external stacks used by a main stack. (Currently all Script only stacks.)
I have the same handler in the main stack as well as in other stacks. I say "pass [handler]" in all cases at the end.
I assume the main stack with get the message first. What determines the hierarchy in other stacks? Is it the order they are loaded on startup?
I have the same handler in the main stack as well as in other stacks. I say "pass [handler]" in all cases at the end.
I assume the main stack with get the message first. What determines the hierarchy in other stacks? Is it the order they are loaded on startup?
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Message hierarchy when external stack are used
If they're all being loaded at the same level (as in "start using xyzzy") then yes, the last one ordered has precedence, and on down the stack of turtles in order of when they were loaded.
If necessary you can change the order by loading one of the stacks again, so that it stays on top of the pile.
If necessary you can change the order by loading one of the stacks again, so that it stays on top of the pile.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Message hierarchy when external stack are used
How are those stacks loaded?
The storage location of a stack doesn't necessarily affect its place in the message path; how you use it does.
The storage location of a stack doesn't necessarily affect its place in the message path; how you use it does.
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
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Message hierarchy when external stack are used
Here is my script in the main stack:
So Lib_1 etc are Script only stacks, loaded one after another. Let us say each stack has the following script:
Code: Select all
local sLibraryPath
on preOpenStack
put specialfolderpath("resources") & "/script/MainFile_behaviour.livecodescript" \
into tBehaviour
set the behavior of stack "MainFile" to the long ID of stack tBehaviour
start using stack tBehaviour
--
put specialFolderPath("resources") & "/script/" into sLibraryPath
use_library "Lib_1" -- script only stacks
use_library "Lib_2"
...
use_library "Lib_n"
end preOpenStack
on use_library pStack
put pStack & ".livecodescript" into tStackName
put sLibraryPath & tStackName into tPath
open stack tPath
start using stack tPath
end use_library
Code: Select all
on rawKeyUp
answer Lib_1
pass rawKeyUp
end rawKeyUp
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Message hierarchy when external stack are used
I would say the the order in which you start using these other stacks places them in the hierarchy. This regardless of the origin of the commands to do so.
In order to rearrange, you would have to "re-start using" them. If you stop using one in the middle, they all collapse, in order.
I think.
Craig
In order to rearrange, you would have to "re-start using" them. If you stop using one in the middle, they all collapse, in order.
I think.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Message hierarchy when external stack are used
Jacque raised a very important question in one of the many sprawling parallel threads posted across the forums on this, and I don't recall seeing the answer: Why is the same script being used as both a behavior and a library?
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
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Message hierarchy when external stack are used
Oh, I don't remember that question. OK so you are saying in these lines:
I have set behavior and in addition I am adding as a library. Does not seem right. I agree. But I just tried removing the second line and a handler is not available to other lib stacks. So although it is set as behaviour the handlers are not seen until I say "start using". Sorry getting a bit too involved and showing my lack of grasp of this area!
Code: Select all
set the behavior of stack "MainFile" to the long ID of stack tBehaviour
start using stack tBehaviour
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Message hierarchy when external stack are used
It sounds like what you want isn't a behavior, but a library.
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
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Message hierarchy when external stack are used
Thanks. Let me mull over it. Didn't think about it in that way
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Message hierarchy when external stack are used
This may help:
http://fourthworld.com/embassy/articles ... _path.html
http://fourthworld.com/embassy/articles ... _path.html
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
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Message hierarchy when external stack are used
What do you know, Richard. Works fine with just library, no behaviour!! Thank you (and Jacqueline).
Kaveh