I’ve been updating some very old scripts, and in several cases I’ve wanted to quickly add a handler containing some ASObjC code, as outlined here:
It occurred to me that this sort of handler is crying out for a clipping, so I wrote one that others might also find useful:
on [[linked-template:handlerName]]([[linked-template:theArg]])
script theScript
property parent : a reference to current application
use framework "Foundation"
on [[linked-template:handlerName]]([[linked-template:theArg]])
[[template:-- Handler code goes here...]]
end [[linked-template:handlerName]]
end script
return theScript's [[linked-template:handlerName]]([[linked-template:theArg]])
end [[linked-template:handlerName]]
[[selected-lines]]
Save it as a .txt
file in your Clippings folder, and it will insert this:
The linking of placeholders means you type the handler name once instead of five times, and the argument name(s) once instead of three times.