• 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: Deivy Marck Petrescu <email@hidden>
  • Date: Sat, 17 Oct 2015 14:19:33 -0400

On Oct 17, 2015, at 2:16 PM, Deivy Marck Petrescu <email@hidden> wrote:

>
> On Oct 17, 2015, at 1:22 PM, S. J. Cunningham <email@hidden> wrote:
>
>> Another rookie error, I suppose.  Why does the first case work and the second fail?
>>
>> -- Case 1
>> handlerName()
>> if errNum of the result ≠ 0 then
>> 	display dialog "Error " & errNum of the result & ": " & errMsg of the result
>> else
>> 	display dialog "No Error"
>> end if
>> --> "Error -1: x"
>>
>> -- Case 2
>> if errNum of handlerName() ≠ 0 then
>> 	display dialog "Error " & errNum of the result & ": " & errMsg of the result
>> 	return
>> end if
>> display dialog "No Error"
>> --> Runtime Error: "Can’t make errNum of "x" into type Unicode text."
>>
>> on handlerName()
>> 	set yyy to "x"
>> 	return {errNum:-1, errMsg:yyy}
>> end handlerName
>>
>> Steve
>> ------------------
>> OS X 10.6.8, AppleScript 2.1.2
>>
>> _______________________________________________
>
> Actually there was something surprising (at least to me) about the "result" (pun intended).
>
> I was not aware that a handler would behave this way.
> Here is the script
>
> if errMsg of handlerName() ≠ "y" then
> 	set k to result
> 	display dialog "k is " & k
> end if
> -->"k is y"
>
> set g to handlerName()
> g's errNum
> ---> -1
> on handlerName()
> 	set yyy to "x"
> 	set zzz to "y"
> 	return {errNum:-1, errMsg:yyy}
> end handlerName
>
> So if you act on the handler, as in the first line of the script, the result of that operation is the last variable declared on the handler.
> I never new that!
>
> Deivy
>

... never knew that!
As in it is new to me!!!



 _______________________________________________
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>)

  • Prev by Date: Re: Return from Handler... What am I Missing Here?
  • Next by Date: Re: Return from Handler... What am I Missing Here?
  • 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