Call, Send, Dispatch message source object

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Call, Send, Dispatch message source object

Post by WaltBrown » Sat Apr 11, 2015 1:05 pm

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
Walt Brown
Omnis traductor traditor

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Call, Send, Dispatch message source object

Post by dunbarx » Mon Apr 13, 2015 3:10 am

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

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Call, Send, Dispatch message source object

Post by WaltBrown » Mon Apr 13, 2015 10:30 am

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.
Walt Brown
Omnis traductor traditor

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 829
Joined: Fri Aug 15, 2008 7:15 am

Re: Call, Send, Dispatch message source object

Post by bangkok » Mon Apr 13, 2015 12:41 pm

Try :

Code: Select all

   answer the long owner of the target

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Call, Send, Dispatch message source object

Post by dunbarx » Mon Apr 13, 2015 3:27 pm

@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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6720
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Call, Send, Dispatch message source object

Post by FourthWorld » Mon Apr 13, 2015 3:38 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Call, Send, Dispatch message source object

Post by dunbarx » Mon Apr 13, 2015 5:19 pm

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

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Call, Send, Dispatch message source object

Post by WaltBrown » Tue Apr 14, 2015 12:00 am

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.
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Call, Send, Dispatch message source object

Post by WaltBrown » Tue Apr 14, 2015 12:03 am

I guess I'm back to this discussion from last month:
http://forums.livecode.com/viewtopic.ph ... lit=pubsub
Walt Brown
Omnis traductor traditor

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2788
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Call, Send, Dispatch message source object

Post by mwieder » Wed Apr 15, 2015 7:45 pm

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.

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Call, Send, Dispatch message source object

Post by WaltBrown » Thu Apr 16, 2015 2:22 pm

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.
Walt Brown
Omnis traductor traditor

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”