• 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: Application-specific code in handler won't execute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application-specific code in handler won't execute


  • Subject: Re: Application-specific code in handler won't execute
  • From: Sander Tekelenburg <email@hidden>
  • Date: Sat, 16 Jul 2005 08:36:47 +0200

At 00:52 -0500 UTC, on 2005/07/16, Bill Planey wrote:

> I don't know if it isn't possible to set up a handler that makes an
>application-specific command, but I wouldn't think so.

You think absolutely wrong.

tell application "iChat"
	set myStatus to (get status) as Unicode text
	my function(myStatus)
end tell

on function(someString)
	tell application "BBEdit"
		activate
		display dialog someString
	end tell
end function

[...]

> on LiteralFix(FindText, ReplaceText)
>     set quote to "\""
>     set TheCommand to "replace " & quote & FindText & quote & " using " &
>quote & ReplaceText & quote & " searching in text 1 of text document 1
>options {search mode:literal, starting at top:false, wrap around:true,
>backwards:false, case sensitive:true, match words:false, extend
>selection:false}"
>     tell application "BBEdit"
>         TheCommand
>    end tell
> end LiteralFix
>
>
> ... The handler does absolutely nothing

Your variable TheCommand is a string. You're telling BBEdit a string...

What you *meant* to do is create a script object, and tell BBEdit to execute
that, for instance something like this:

tell application "BBEdit"
	my function()
end tell

on function()
	set TheCommand to "activate
display dialog \"beep beep\""
	tell application "BBEdit"
		run script TheCommand
	end tell
end function

Note that although a script object can be created from a string, you'll have
to make sure it has all the returns and escape characters in the right
places. This road is really only useful when it's the only one available (for
instance, in a script that receives code as a string and needs to execute
that).

Script objects can be useful, but in this case I see no need for that
approach. if I were you I'd keep it simple:

tell application "BBEdit"
	my LiteralFix(" Ct ", " Court ") -- Court
   my LiteralFix(" Cir ", " Circle ") -- Circle
   my LiteralFix(" St ", " Street ") -- Street
   my LiteralFix(" Dr ", " Drive ") -- Drive
   my LiteralFix(" Ln ", " Lane ") -- Lane
   my LiteralFix(" Ave ", " Ave. ") -- Avenue
   my LiteralFix(" Rd ", " Road ") -- Road
   my LiteralFix(" Blvd ", " Blvd. ") -- Boulevard
end tell

on LiteralFix(FindText, ReplaceText)
	tell application "BBEdit"
		replace FindText using ReplaceText searching in text 1 of text document
1 options {search mode:literal, starting at top:false, wrap around:true,
backwards:false, case sensitive:true, match words:false, extend
selection:false}
	end tell
end function


--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
 _______________________________________________
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: 
 >Application-specific code in handler won't execute (From: Bill Planey <email@hidden>)

  • Prev by Date: Re: Application-specific code in handler won't execute
  • Next by Date: Re: what happened to Mail's scripts menu?
  • Previous by thread: Re: Application-specific code in handler won't execute
  • Next by thread: silly (but huge) bug in the Attach Script to Folder script
  • Index(es):
    • Date
    • Thread