Non uso Yojimbo . Tuttavia, i whosefiltri AppleScript devono essere applicati a un oggetto plurale . Mentre selection è esso stesso un elenco di oggetti, selection-objectè una singola entità, quindi non può essere emanata da whose. items of selectionsarebbe, in teoria, una raccolta più appropriata da filtrare, ma itemsgenererebbe semplicemente un riferimento listche, in effetti, non può neppure essere filtrato.
In altre app che usano selection-objects, la selectionproprietà è fastidiosamente parzialmente riservata e quindi non è in grado di filtrare whose.
Se fosse possibile, length of its name(che è la sintassi che verrebbe utilizzata in tale filtro) non è una proprietà valida su cui filtrare.
Sfortunatamente, in base al modo in cui funzionano altre app con un selectionoggetto simile , dovrai scorrere manualmente l'elenco.
Tuttavia, se l'efficienza è un problema, ecco un modo abbastanza efficiente per farlo, come illustrato utilizzando l' selectionoggetto in Finder , che è un elenco di file e cartelle:
property Finder : application "Finder"
to filterItems from (L as list) thru filter as handler into |L*| as list : null
local L, |L*|, filter
if |L*| = null then set |L*| to {}
script filteredItems
property array : L
property fn : filter
property list : |L*|
end script
tell the filteredItems to repeat with x in its array
if fn(x) = true ¬
then set ¬
end of its list ¬
to x's contents
end repeat
return the list of filteredItems
end filterItems
on characterCount(x)
set |name| to the name of x
|name|'s length > 12
end characterCount
filterItems from (Finder's selection) thru characterCount