Monday, November 08, 2010 at 12:01 AM.
system.verbs.apps.Finder.finderParam
on finderParam (path) { << assumes Scriptable Finder
<<Make sure that parameters are not full path strings
<<Where the "Finder Scripting Guide English Edition", and the Finder's
<<AppleScript Dictionary specify that some event parameter is an object
<<specifier, Finder will also accept alias records or FSSpec records.
<<However, it will not accept a full path name string. This verb is used
<<to "sanitize" full path strings. After several experiments, it appears that
<<the least bad way to do this is to coerce them to filespecs. In some
<<cases, this choice results in a strange error number 5038 if Finder
<<is asked to operate on missing files.
case typeOf (path) {
filespecType {
if string (path) endsWith ":" {
return (filespec (string.popTrailing (path, ':')))}
else {
return (path)}};
stringType {
return (alias (path))};
string4Type { << handles things like open (selection)
return (objspec (path))};
listType {
local (result = {}, x);
for x in path {
result = result + Finder.finderParam (x)};
return (result)}}
else { << Either Finder can deal with it or Finder will report an error later
return (path)}}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.