Re: Application-specific code in handler won't execute
Re: Application-specific code in handler won't execute
- Subject: Re: Application-specific code in handler won't execute
- From: Andrew Oliver <email@hidden>
- Date: Fri, 15 Jul 2005 23:07:24 -0700
Title: Re: Application-specific code in handler won't execute
On 7/15/05 10:52 PM, "Bill Planey" <email@hidden> wrote:
Hello,
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. I successfully created handlers for Word that send Visual Basic commands.
But I cannot seem to create a handler that will work which has BBEdit perform some simple search/replace tasks. The purpose, obviously, is simply to save space in the code.
I could do it like this:
tell application "BBEdit"
activate
-- Circle
replace " Cir " using " Circle " 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}
-- Street
replace " St " using " Street " 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
...But I would rather do it more compactly, like the following:
[snip]
... The handler does absolutely nothing, even though the search candidates are there in the file. Maybe is has something to do with the quote marks?
Any ideas?
Am I missing something here. Why are you trying to build a string that contains the AppleScript syntax. Why not just run the script directly:
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
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 LiteralFix
Failing that, if you do want to build a complete string that contains the AppleScript code, use ‘run script’ to execute it, but it will need to include the ‘tell application “BBEdit’’ statements.
Andrew
:)
_______________________________________________
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