Handlers and Scope

Ken Ray kray at sonsothunder.com
Wed Dec 7 14:30:02 EST 2005


> Within my application the fuctions I have written don't return values in
> that case, if I understand correctly; they should be handlers.  How do I
> define a handler?

Although Rob gave you the full answer, the simple answer is "change
'function' to 'on' and you're done". :-)

That is, a function called DoMyStuff:

function DoMyStuff pWhatToDo
  -- does a bunch of stuff and doesn't return a value
end DoMyStuff

which is called like:

  get DoMyStuff("bark")

  -- I used "get" since it doesn't need to return a value, wheras
  -- it's better to use "put" when you want the returned value

becomes a handler when you change 'function' to 'on':

on DoMyStuff pWhatToDo
  -- does a bunch of stuff and doesn't return a value
end DoMyStuff

and is called like this:

  DoMyStuff "bark"

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list