Re: Scripting Sherlock engine
Re: Scripting Sherlock engine
- Subject: Re: Scripting Sherlock engine
- From: Kai Edwards <email@hidden>
- Date: Fri, 13 Sep 2002 14:40:51 +0000
on Fri, 13 Sep 2002 00:42:46 +0100, "Philippe GRUCHET"
<email@hidden> wrote:
>
Hello,
>
>
Just a little note about "Find by Content Indexing":
>
In Mac OS 9 other than English/US version, the name of this app is
>
translated.
>
>
For example, in French, the name is "Indexation du contenu".
>
To share a such script, I think that it is more appropriate to write:
>
>
=========
>
tell application "Finder"
>
set theApp to application file id "fbca" as string
>
set this_filepath to result as text
>
>
-- Is it better to use the delimiters...?
>
set x to offset of ":" in (reverse of every character of this_filepath) as
>
string
>
set theAppName to ((characters -(x - 1) thru -1 of this_filepath) as text)
>
>
repeat until process theAppName exists
>
end repeat
>
set visible of process theAppName to false
>
end tell
>
=========
Good point, Philippe.
BTW, I'm pleased to hear that the Sherlock tell block of my original
suggestion did the trick! :-)
The second block was, of course, intended as a simple example - so I didn't
include any of the usual traps. In scripts for general distribution, I would
normally use 'application file id' anyway - since it avoids those irritating
"Where is 'XXX'?" dialogs that can appear (for architectural as well as
language reasons) when scripts are run on other machines.
It's also worth bearing in mind that text manipulation routines within a
Finder tell block may result in confusion on some systems. So, for even
greater universality, I'd suggest moving them outside the tell block -
perhaps something like this:
-------------------------------------------------------------------------
tell application "Finder" to set appPath to [NO BREAK]
application file id "fbca" as string
set x to offset of ":" in appPath's text items's reverse as string
set appName to appPath's text (1 - x) thru -1
tell application "Finder"
repeat until process appName exists
end repeat
set process appName's visible to false
end tell
-------------------------------------------------------------------------
For the benefit of anyone still grappling with text grunges (and to avoid
any accusations of rank favouritism from those who aren't ;-), I guess we
should also mention AppleScript's text item delimiters as another way to do
the job:
-------------------------------------------------------------------------
tell application "Finder" to set appPath to [NO BREAK]
application file id "fbca" as string
set {tid, text item delimiters} to {text item delimiters, ":"}
set {appName, text item delimiters} to {appPath's text item -1, tid}
tell application "Finder"
repeat until process appName exists
end repeat
set process appName's visible to false
end tell
-------------------------------------------------------------------------
At the end of the day, however, I suppose we could just simplify the whole
routine to this:
-------------------------------------------------------------------------
tell application "Finder"
set appName to (application file id "fbca")'s name
repeat until process appName exists
end repeat
set process appName's visible to false
end tell
-------------------------------------------------------------------------
For this particular purpose, and given the negligible speed differences
(OMM) between each of the above methods, I'd personally favour the latter.
(But then I'm just a simple country boy - so no surprises there!) ;-)
Best wishes.
Kai
--
email@hidden
email@hidden
_______________________________________________
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.