• 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: Handlers in applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handlers in applications


  • Subject: Re: Handlers in applications
  • From: Chris Espinosa <email@hidden>
  • Date: Sat, 12 Feb 2005 09:29:22 -0800

On Feb 12, 2005, at 9:17 AM, Irwin Poche wrote:

There has to be a simple solution to this but it eludes me.

It appears that applications can't deal with simple condition handlers.  This example issues an Applescript Error "TextEdit got an error: Can't continue simplicity."  Same result for iPhoto 5.0.1 and iTunes...

    tell application "TextEdit"

        activate

        simplicity("testing")

    end tell

    on simplicity(xxx)

        display dialog xxx

    end simplicity

but this works...

    simplicity("testing")

    on simplicity(xxx)

        display dialog xxx

    end simplicity

The first example will work by using a tell me to before simplicity but that seems unnecessary and kludgy.


Please see the AppleScript Language Reference Guide, page 284, "Subroutines."

If you need to call a subroutine from within a Tell statement, you must use the 

reserved words of me or my to indicate that the subroutine is part of the script 

(not a command that should be sent to the object of the Tell statement). 

For example, the minimumValue subroutine call in the following Tell statement is 

unsuccessful, even if the script contains the minimumValue routine defined in “A 

Sample Subroutine” (page 282), because AppleScript sends the minimumValue 

command to AppleWorks. If you run this script, you get an error message 

saying that AppleWorks does not understand the minimumValue message. 


tell front document of application "AppleWorks" 

    minimumValue(12, 400) 

copy result as string to word 10 of text body

  end tell 

--result: An error, because AppleWorks doesn’t 

-- understand the minimumValue message. 

 


If you use the words of me in the subroutine call, as shown in the following Tell 

statement, the subroutine call is successful, because AppleScript knows that the 

subroutine is part of the script. 


tell front document of application "AppleWorks" 

minimumValue(12, 400) of me 

copy result as string to word 10 of text body 

end tell 

--result: The subroutine call is successful. 


You can use the word my before the subroutine call as a synonym for the words 

of me after the subroutine call. For example, the following two subroutine calls 

are equivalent: 


minimumValue(12, 400) of me 

my minimumValue(12, 400) 


Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Handlers in applications (From: Irwin Poche <email@hidden>)

  • Prev by Date: Re: Handlers in applications
  • Next by Date: suspend execution of a script
  • Previous by thread: Re: Handlers in applications
  • Next by thread: Re: Handlers in applications
  • Index(es):
    • Date
    • Thread