Can't pass a parameter to an handler [Solved]

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Can't pass a parameter to an handler [Solved]

Post by atout66 » Wed May 14, 2014 2:19 pm

Hi to all,

I want to send a parameter via a <send> command, but I don't find the right syntax... Here is my code:

Code: Select all

send updateHistorique leMot to laCard 
<laCard> is the long ID of the card and the parameter is <leMot > for the handler <updateHistorique> in card <laCard>

I also tried : send updateHistorique,leMot to laCard but it doen't work either...

Any idea what's wrong ?
Thanks in advance, Jean-Paul.
Last edited by atout66 on Wed May 14, 2014 5:09 pm, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Can't pass a parameter to an handler

Post by Mark » Wed May 14, 2014 2:21 pm

Hi Jean-Paul,

There are 2 ways to do this:

Code: Select all

    put "mot" into leMot
    send "updateHistorique leMot" to laCard 
or

Code: Select all

    put "mot" into leMot
    send "updateHistorique" && quote & leMot & quote to laCard 
Usually the first method works fine but in rare cases you need the second method.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Can't pass a parameter to an handler

Post by FourthWorld » Wed May 14, 2014 4:40 pm

The send command is ideal for timers, using "send <msg> in <time>". For sending a message without delay you'll find better performance and greater convenience using the dispatch command instead, e.g.:

Code: Select all

dispatch "someMessage" to tSomeObj with tSomeArg
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Can't pass a parameter to an handler

Post by Mark » Wed May 14, 2014 5:05 pm

Hi,

Note that dispatch needs checking the result, while send will cause an execution error of the engine couldn't handle the message. In most cases, I prefer the send command.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Can't pass a parameter to an handler

Post by atout66 » Wed May 14, 2014 5:09 pm

Thanks for your help Mark and Richard.

I better understand now... :wink:

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply