• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Return from Handler... What am I Missing Here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Return from Handler... What am I Missing Here?


  • Subject: Re: Return from Handler... What am I Missing Here?
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 18 Oct 2015 11:42:24 +1100

On 18 Oct 2015, at 7:48 AM, S. J. Cunningham <email@hidden> wrote:
>
> But why does it return "x" instead of {errNum:-1, errMsg:"x"}

Because not all statements return a result. When you call your handler, the line:

	set yyy to "x"

returns a result ("x"). But the next line:

	return {errNum:-1, errMsg:yyy}

returns a value to the caller, but it does not return a result. So at the point the handler returns, result is still "x".

In Case 1 you called the handler like this:

handlerName()

That statement returns a result, which is the value returned by the handler ({errNum:-1, errMsg:yyy}).

In Case 2 you called it like this:

if errNum of handlerName() ≠ 0 then

That's a control statement that doesn't return a result, which means the result variable remains as it was before that statement: "x".

As others have said, steer clear of the result variable. It has the potential to cause too much grief.

--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >Return from Handler... What am I Missing Here? (From: "S. J. Cunningham" <email@hidden>)
 >Re: Return from Handler... What am I Missing Here? (From: Deivy Marck Petrescu <email@hidden>)
 >Re: Return from Handler... What am I Missing Here? (From: "S. J. Cunningham" <email@hidden>)

  • Prev by Date: Re: Return from Handler... What am I Missing Here?
  • Next by Date: AppleScript grammar
  • Previous by thread: Re: Return from Handler... What am I Missing Here?
  • Next by thread: Re: Return from Handler... What am I Missing Here?
  • Index(es):
    • Date
    • Thread