Page 1 of 1

Call, Send, Dispatch message source object

Posted: Sat Apr 11, 2015 1:05 pm
by WaltBrown
I'm having a senior moment...

If I use Send, Call, or Dispatch between independent stacks, how does the message handler identify the source of the message? I know I've seen it somewhere (I've used it in the past) but now can't recall the answer...

Thanks, Walt

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 3:10 am
by dunbarx
Walt.

Are you thinking of the fact that "dispatch" command can return information about whether the message was handled or not, or passed?

Craig Newman

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 10:30 am
by WaltBrown
Thanks Craig. No. Here's a better description.

I have a number of utility stacks I use when parsing multilingual and/or multimedia content, for things like vocabulary testing, significant phrase or named entity identification, spell checking, statistics, protocol compliance, etc. They are each independent (and run under the IDE at the moment).

Many of them may call functions or send messages to each other (I am moving toward sending async messages to each other to reduce dependencies and allow throttling). A given utility stack may not know which other utility stack sent the message. I am hoping to avoid having to include the sender's ID in each message's parameter list, as I thought it was already available. But that might be my muddled memory recalling a different programming language.

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 12:41 pm
by bangkok
Try :

Code: Select all

   answer the long owner of the target

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 3:27 pm
by dunbarx
@Bangkok
answer the long owner of the target
This would give the owner of the target stack, no?

@Walt. I am not sure there is a "receipt" for the sending handler or its environment. I could be wrong. When Bangkok, posted, unless I am misunderstanding him, I initially thought it was a wonderful coup. But I do not think that is what you need. You may indeed have to send that receipt along with any parameters.

Oh, yes. I could be wrong.

Craig

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 3:38 pm
by FourthWorld
You can obtain info about the calling chain from the executionContexts, but I wonder if maybe what's really needed here is to consider driving this with behavior scripts.

Re: Call, Send, Dispatch message source object

Posted: Mon Apr 13, 2015 5:19 pm
by dunbarx
AHA! Richard makes a point. Behaviors would also allow each button to execute its own particular actions, just like a group script, but more importantly, the local variable "me" would refer to the child object. By testing "me", or the owner of "me", you can derive the source button info without having to send that data along with the message.

Much more modern way to do things...

Craig

Re: Call, Send, Dispatch message source object

Posted: Tue Apr 14, 2015 12:00 am
by WaltBrown
Thanks. Bangkok, "owner" gives the owner of the handler in the receiving stack.

Richard, thanks, same thing, "executionContexts" in the handler only gives info about the receiving stack.

On behaviors, how would that work? Would the behavior live in the stack that will eventually receive the message? In that case I would still need advance knowledge of the sending stack in the receiving stack, which I don't have. Or the stacks would have to register with each other to "collect" appropriate behaviors for the context.

Re: Call, Send, Dispatch message source object

Posted: Tue Apr 14, 2015 12:03 am
by WaltBrown
I guess I'm back to this discussion from last month:
http://forums.livecode.com/viewtopic.ph ... lit=pubsub

Re: Call, Send, Dispatch message source object

Posted: Wed Apr 15, 2015 7:45 pm
by mwieder
Walt- I'm missing something about
Richard, thanks, same thing, "executionContexts" in the handler only gives info about the receiving stack.
The executionContexts gives you the call stack, showing exactly what chain of events led to the current state. If you examine it, you'll see the original caller, and everything else in the chain, including the long id of the objects.

Re: Call, Send, Dispatch message source object

Posted: Thu Apr 16, 2015 2:22 pm
by WaltBrown
Thanks, you are right. I was trying it out in an existing set of stacks which was overcomplicating my logging. I made a test set of two stacks with just the calling code and saw that I was wrong, and it did get the entire context.