custom commands and custom handlers

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jim1001
Posts: 143
Joined: Fri Jan 29, 2016 6:25 pm

custom commands and custom handlers

Post by jim1001 » Fri Jun 03, 2016 5:28 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10324
Joined: Wed May 06, 2009 2:28 pm

Re: custom commands and custom handlers

Post by dunbarx » Fri Jun 03, 2016 6:43 pm

Hi.

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

Craig Newman

jim1001
Posts: 143
Joined: Fri Jan 29, 2016 6:25 pm

Re: custom commands and custom handlers

Post by jim1001 » Fri Jun 03, 2016 8:14 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: custom commands and custom handlers

Post by jacque » Sat Jun 04, 2016 4:13 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: custom commands and custom handlers

Post by Klaus » Sun Jun 05, 2016 5:25 pm

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

jim1001
Posts: 143
Joined: Fri Jan 29, 2016 6:25 pm

Re: custom commands and custom handlers

Post by jim1001 » Tue Jun 07, 2016 11:42 am

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: custom commands and custom handlers

Post by mwieder » Wed Jun 08, 2016 8:25 pm

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.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: custom commands and custom handlers

Post by Mikey » Thu Jun 09, 2016 2:11 pm

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.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: custom commands and custom handlers

Post by mwieder » Thu Jun 09, 2016 3:48 pm

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,

Post Reply