Handler for returning a value

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
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Handler for returning a value

Post by jalz » Sat May 24, 2014 10:46 am

Hi all,

Just a general question as i explore refactoring some of my long code into smaller effiecient handlers i can call again. Am i right in thinking that only a function can return a value?

Thanks
Jalz

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

Re: Handler for returning a value

Post by Klaus » Sat May 24, 2014 11:28 am

Hi Jaz,
Am i right in thinking that only a function can return a value?
no Sir! :D

A handler can also return a value, but you have to retrieve THE RESULT :D

Example:

Code: Select all

command anyhanlder
  ...
  dothat
  put the result into tReturnedValue
  ## Do somehting with that variable
end anyhandler

command dothat
  ## do something here and output the result
  ## Cheap-o example:
  put 10*20 into tResult
  RETURN tResult
end dothat
Hope that helps!


Best

Klaus

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Handler for returning a value

Post by jalz » Sat May 24, 2014 11:40 am

Thanks Klaus - just what i was looking for :)

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

Re: Handler for returning a value

Post by Klaus » Sat May 24, 2014 11:47 am

Hi Jalz,
jalz wrote:Thanks Klaus - just what i was looking for :)
I know! :D


Best

Klaus

Post Reply