• 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
Handlers and Tell Blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handlers and Tell Blocks


  • Subject: Handlers and Tell Blocks
  • From: Paul Berkowitz <email@hidden>
  • Date: Tue, 27 Aug 2002 13:51:33 -0700

Handlers require their own internal application tell blocks and are
impervious to application tell blocks in which they may be called. So does
that mean that there is nothing equivalent to the AppleEvent sent to an
application within another application's tell block if you call the handler
there, slowing things down? I'm wondering about the relative virtues of
doing just that, even where a second application's object is involved,
rather than creating a whole series of possibly unnecessary variables just
so a handler can be called outside a tell block.

propertyA, propertyB, etc. are all keywords of app2, namely properties of
its object app2Object, whose values evaluate to strings.


I.e.:


Method 1: handlers called within a tell block (in Handler1)


tell application "App 1"
set app1Object to object "something"
end tell

tell application "App 2"
set app2Object to element "something else"
end tell

set app1Object to my Handler1(app1Object, app2Object)

on Handler1(app1Object, app2Object)
tell application "App 2"
tell app2Object
set app1Object to my Handler2(app1Object, propertyA)
set app1Object to my Handler3(app1Object, propertyB)
end tell
end tell
return app1Object
end Handler1

on Handler2(app1Object, stringValue)
tell application "App1"
set propertyX of app1Object to stringValue
end tell
return app1Object
end Handler2

on Handler3(app1Object, stringValue)
tell application "App1"
set propertyY of app1Object to stringValue
end tell
return app1Object
end Handler3



Method 2: create some extra variables to get out of tell blocks



tell application "App 1"
set app1Object to object "something"
end tell

tell application "App 2"
set app2Object to element "something else"
end tell

set app1Object to my Handler1(app1Object, app2Object)

on Handler1(app1Object, app2Object)
tell application "App 2"
set varA to app2Object's propertyA
set varB to app2Object's propertyB
end tell

set app1Object to my Handler2(app1Object, varA)
set app1Object to my Handler3(app1Object, varB)
return app1Object
end Handler1

on Handler2(app1Object, stringValue)
tell application "App1"
set propertyX of app1Object to stringValue
end tell
return app1Object
end Handler2

on Handler3(app1Object, stringValue)
tell application "App1"
set propertyY of app1Object to stringValue
end tell
return app1Object
end Handler3



--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Need help in scripting for Canto Cumulus 5.0.10
  • Next by Date: Internet Explorer 5.1 won't retain helper pref?
  • Previous by thread: Need help in scripting for Canto Cumulus 5.0.10
  • Next by thread: Re: Handlers and Tell Blocks
  • Index(es):
    • Date
    • Thread