I'm new to applescript and even this community, so this question seems to odd. If so,I'm sorry. But I can't find answers in googling. So let me ask.
When I ran the code
tell application "Evernote"
set theNote to item 1 of selection
set theTitle to (title of theNote)
end tell
I got an error that says
/var/folders/fm/k76y42cs1y98bjwfyf951q1r0000gn/T/vbkvTSQ/55:47:53: execution error: Evernote got an error: Can’t make item 1 of selection into type specifier. (-1700)
but if I run below,
tell application "Evernote"
set theNote to (selection)
set theNote to item 1 of theNote
set theTitle to (title of theNote)
end tell
I could get expected result.
Why does this error happen? I can't see the deffernce of two codes.
Applescript's implied get
strikes again!!
Try doing this instead:
tell application "Evernote"
set theNote to item 1 of (get selection)
set theTitle to (title of theNote)
end tell
Applescript is well meaning, but it hides a lot of implementation details, which makes some errors seem more random than they are. The pitfalls of the "implied get command" have been covered pretty well already, so I'll just summarize with a quote.
One thing that can cause problems is the command "get". In general when you run a command like "name of me" the command get is implied so you're really running "get name of me". The problem is that the implied "get" is not always the case. So sometimes you have to explicitly say "get". Whenever I have a problem like yours the first thing I try is to add "get" to the command...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With