Send and the context

Bob Sneidar bobsneidar at iotecdigital.com
Thu Feb 6 00:00:02 EST 2014


I read from the dictionary:

When the send command is used the stack containing the target handler temporarily becomes the defaultStack. All object references in the message are evaluated in the current context i. e. the defaultStack. Therefore references within the message that refer to "this card" or "this stack" will be referring to the card or stack where the target handler is located. 

Ok. So I put a handler in the script of card “Database Setup” called “test”

on test
	put the short name of this card
end test

I then go to another card called “Main” and create a button whose script reads:

on mouseUp
	send test to card “Database Setup”
end mouseup

So now shouldn’t I get “Database Setup” in the message box, and NOT “Main”? Isn’t this the whole point to using send vs. dispatch? BTW I get the same results using dispatch. If both SEND and DISPATCH produce the same results in regard to the current context, then why not ALWAYS use DISPATCH seeing that you can pass arguments with DISPATCH?

Reason I ask is I have a card that I want to reference objects on, which may not be on the current card, and in fact may not even be in the current stack! I really do not want to reference these objects using long file names and such. Very tedious. 

At present I have a workaround, but kludges bother me, and at any rate if send does not have the effect on the message path that the dictionary seems to indicate, then either I misunderstand (not all that far fetched) or else it’s a bug. 

Bob



More information about the use-livecode mailing list