Page 1 of 1

custom commands and custom handlers

Posted: Fri Jun 03, 2016 5:28 pm
by jim1001
Can anyone tell me why you would use a custom handler as on this page http://lessons.livecode.com/m/4071/l/16 ... ers-part-1 with this syntax

Code: Select all

on myCommand
in preference to a custom command with this syntax

Code: Select all

command myCommand
as on this page http://lessons.livecode.com/m/4603/l/44 ... g-a-button?

Or are these two different names and syntaxes for the same thing?

The user guide entry for Custom Commands gives the syntax

Code: Select all

on myCommand
but doesn’t mention the syntax

Code: Select all

command myCommand
.

The app building course on many occasions uses

Code: Select all

command myCommand
but I don’t recall seeing the syntax

Code: Select all

on myCommand
.


Thanks!
Jim

Re: custom commands and custom handlers

Posted: Fri Jun 03, 2016 6:43 pm
by dunbarx
Hi.

I go way back. I use "on", not "command". But these are synonyms.

Craig Newman

Re: custom commands and custom handlers

Posted: Fri Jun 03, 2016 8:14 pm
by jim1001
Thanks Craig - good to know! I thought I was maybe missing something since it wasn't clear in the user guide or dictionary.

Best wishes,
Jim

Re: custom commands and custom handlers

Posted: Sat Jun 04, 2016 4:13 pm
by jacque
The "command" token is meant to help distinguish between messages the engine sends and custom handlers you write yourself. So you would use "on mouseUp" because that's a built in message, and "command myOwnHandler" for those you've written.

They do act as synonyms functionally.

Re: custom commands and custom handlers

Posted: Sun Jun 05, 2016 5:25 pm
by Klaus
jacque wrote:The "command" token is meant to help distinguish between messages the engine sends and custom handlers you write yourself. So you would use "on mouseUp" because that's a built in message, and "command myOwnHandler" for those you've written.
Exactly!

And once upon a time the mothership advised us to really make this difference
due to possible future changes in the engine, which would make this actually neccessary!

Which however did not happen so far... :D

Re: custom commands and custom handlers

Posted: Tue Jun 07, 2016 11:42 am
by jim1001
Jacque, Klaus,

Thanks for your help. I hope at some point the user guide, lessons and dictionary will be updated to say these are synonyms and include the explanations you've given.

Best wishes,
Jim

Re: custom commands and custom handlers

Posted: Wed Jun 08, 2016 8:25 pm
by mwieder
I am constantly being reminded that synonyms are discouraged. Nonetheless, these are synonyms and I use them in the manner described above, with the addition that anything that will be the object of a "send" or "dispatch" command I treat as a message, and therefore use the "on" format.

The "on" format has been part of the language since the days of the dinosaurs, and changing that would break nearly every stack in existence. The "command" format, while newer, is now a part of the language, and thus also won't change without breaking backward compatibility.

Re: custom commands and custom handlers

Posted: Thu Jun 09, 2016 2:11 pm
by Mikey
Why are synonyms discouraged? Having multiple ways to write the same thing allows more folks express themselves in a manner that suits them. It also makes the language feel more natural and less syntactic. If you have ever yelled at your phone because Siri/Cortana/Alexa/Google Now are soooooooooooooooooooo STUPID, you get the idea.

Re: custom commands and custom handlers

Posted: Thu Jun 09, 2016 3:48 pm
by mwieder
My guess is the team follows Churchill rather than Orwell.
But at any rate, I think the reasoning is that too many choices confuse users.
Go figger,