The send command vs the call command
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
The send command vs the call command
Make a new stack
Make 2 cards
On card 1 create a text field and name it "theField"
In field "theField" script write the custom command:
on thisCommand
put "Blue" into field "theField"
end thisCommand
On card 2 create a button
on mouseUp
send "thisCommand" to field "theField" of card 1
end mouseUp
Press the button on card 2 and see if it works;
You should get this error:
field "theField": execution error at line 2 (Chunk: no such object) near "theField", char 15
if however you change 'thisCommand' to say:
on thisCommand
put "Blue" into field "theField" of card 1
end thisCommand
Then it works and puts the word "Blue" into the field.
I don't understand how the command cannot find the field in the first example and causes the error.
If I were to call this command from card 1 from a similar button it would work.
Make a button on card 1 and in the script write:
on mouseUp
send "thisCommand" to field "theField"
end mouseUp
Does this mean every object I reference in a custom command that I intend to use with the 'send' command from another card need to be explicitly declared ( of card 1 ).
I assume the answer is yes.
After having just read the manual section entitled "The send Command versus the call Command" I find this behaviour peculiar and contrary to the manual.
Can someone correct me?
Make 2 cards
On card 1 create a text field and name it "theField"
In field "theField" script write the custom command:
on thisCommand
put "Blue" into field "theField"
end thisCommand
On card 2 create a button
on mouseUp
send "thisCommand" to field "theField" of card 1
end mouseUp
Press the button on card 2 and see if it works;
You should get this error:
field "theField": execution error at line 2 (Chunk: no such object) near "theField", char 15
if however you change 'thisCommand' to say:
on thisCommand
put "Blue" into field "theField" of card 1
end thisCommand
Then it works and puts the word "Blue" into the field.
I don't understand how the command cannot find the field in the first example and causes the error.
If I were to call this command from card 1 from a similar button it would work.
Make a button on card 1 and in the script write:
on mouseUp
send "thisCommand" to field "theField"
end mouseUp
Does this mean every object I reference in a custom command that I intend to use with the 'send' command from another card need to be explicitly declared ( of card 1 ).
I assume the answer is yes.
After having just read the manual section entitled "The send Command versus the call Command" I find this behaviour peculiar and contrary to the manual.
Can someone correct me?
-
- Posts: 1201
- Joined: Sun Apr 24, 2011 2:17 am
Re: The send command vs the call command
yes, very interesting question and behaviours.
Thats an intricate question for your first post.
Welcome to the forums.
I'd prefer you upload a complete .livecode project to make it easier and to ensure we're testing the same project.
I thnk error is expecting field "theField" to be on card 2 and can't find it.
But I've drawn the same logical conclusion from your post without actually testing it myself.
Thats an intricate question for your first post.
Welcome to the forums.
I'd prefer you upload a complete .livecode project to make it easier and to ensure we're testing the same project.
I thnk error is expecting field "theField" to be on card 2 and can't find it.
But I've drawn the same logical conclusion from your post without actually testing it myself.
5.8.6 The send Command versus the call Command
The call command is similar to the send command. Like the send command, the
call command sends a message to the specified object, allowing you to use handlers
that aren't in the message path.
The difference between send and call is how they handle object references in the
handler that is triggered by the sent message. If the message is sent by the send
command, object references in the handler are treated relative to the object you sent the
message to.
For example, suppose card 1 of a stack contains the following handler:
If a handler in the script of card 3 uses the send command to send a "showCard"Code: Select all
on showCard answer the number of this card end showCard
message to card 1, the dialog box displays "1", the number of the card the handler is on.
However, if the same handler uses the call command instead, the dialog box displays
"3", the number of the card that used the call command. In other words, handlers that
are triggered by the send command use the context of the object the handler is in, while
handlers that are triggered by the call command use the context of the object that
triggered the handler.
All my best,
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Re: The send command vs the call command
I would love to upload the .livecode file but the file extension is not allowed. neither is .txt and I can't trick it with .jpg
As far as I can tell, this is rubbish. This is frustrating. I'm trying to learn livecode and when I write myself an example to test, it doesn't behave anything like the manual entry.The difference between send and call is how they handle object references in the
handler that is triggered by the sent message. If the message is sent by the send
command, object references in the handler are treated relative to the object you sent the
message to.
Re: The send command vs the call command
Try zipping the file first, it should be accepted for upload then.
-
- Posts: 1201
- Joined: Sun Apr 24, 2011 2:17 am
Re: The send command vs the call command
There are some restrictions for new forum members.
Hyperlinks were allowed only after 10 posts or 7 days.
To keep spammers away.
Don't know the rules for attachments.
Hyperlinks were allowed only after 10 posts or 7 days.
To keep spammers away.
Don't know the rules for attachments.
All my best,
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Re: The send command vs the call command
thanks guys. I will be interested to see what I did wrong.
Re: The send command vs the call command
Hi nlexa,
you did nothing wrong and this is correct behavior!
This is not easy to explain...
The "world" of LiveCode consists of the current card only, so when you "send" you handler to a button on another card,
that handler will also only "see" the current card and does not find that namely field!
But it DOES if we are (the LiveCode "world" is) on the card with the button!
So you should simply add a descriptor of that card (number or name) and everything will be fine:
Just like you did in your "send" handler!
...
send "thisCommand" to field "theField" of card 1
...
Best
Klaus
you did nothing wrong and this is correct behavior!

This is not easy to explain...
The "world" of LiveCode consists of the current card only, so when you "send" you handler to a button on another card,
that handler will also only "see" the current card and does not find that namely field!
But it DOES if we are (the LiveCode "world" is) on the card with the button!
So you should simply add a descriptor of that card (number or name) and everything will be fine:
Code: Select all
on thisCommand
put "Blue" into field "theField" OF CD "name of card here"
end thisCommand
...
send "thisCommand" to field "theField" of card 1
...
Best
Klaus
Re: The send command vs the call command
Thanks Klaus! I thought that might be the case because I tried using:
on mouseUp
go to card 1
send thisCommand to field "theField" of card 1
end mouseUp
this works because it goes to the card before it sends the message to it.
In any case I had to hear it from someone else to be sure that:
on mouseUp
go to card 1
send thisCommand to field "theField" of card 1
end mouseUp
this works because it goes to the card before it sends the message to it.
In any case I had to hear it from someone else to be sure that:
The "world" of LiveCode consists of the current card only
Re: The send command vs the call command
Yep, it's a small world, but the best (and only) we have 
