Yes, it returns an object; namely, the empty list
Both work in Applescript. I can’t give you a technical answer here. Perhaps, some scoping rule is taking place there. But we see that
add is an application method. So,
Application(‘OmniFocus’).add would be correct.
I see good ideas on your script. Perhaps useful would be to:
- Separate construction of values from effects (console.log, displaying dialogs, …).
- Whenever there is a need to apply some transformation to a collection, I.e. a list, trying to think what would be the transformation on one item and then generalize it.
Also, I would suggest making a script to add tags to selected tasks and then, when new concepts are settling down, try to experiment also with the objects obtained in .containingProject property.
So, in a functional way, I would approach the problem of adding a specific tag to selected tasks:
What is the effect I am after? The addition of a list of tag objects to a single task.
addTag :: [OF Tag] -> [OF Task]
const addTag = (oTag, oTask) => Application
What are the values I need to obtain? A filtered list of tasks.
onlyTasks :: [OF Item] -> [OF Task]
const onlyTasks = seln =>
ObjectSpecifier.classOf(x) == 'task'
Now, I need to apply i.e. —
map — that transformation —
addTag — to my filtered list of tasks.