小编use*_*926的帖子

无法理解在 Applescript 中分配变量时发生的错误

我是 applescript 甚至这个社区的新手,所以这个问题似乎很奇怪。如果是这样,我很抱歉。但是我在谷歌搜索中找不到答案。所以让我问一下。

当我运行代码时

tell application "Evernote"
    set theNote to item 1 of selection
    set theTitle to (title of theNote)
end tell
Run Code Online (Sandbox Code Playgroud)

我收到一个错误,说

/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)
Run Code Online (Sandbox Code Playgroud)

但如果我跑到下面

tell application "Evernote"
    set theNote to (selection)
    set theNote to item 1 of theNote
    set theTitle to (title of theNote)
end tell
Run Code Online (Sandbox Code Playgroud)

我可以得到预期的结果。

为什么会发生这个错误?我看不到两个代码的区别。

applescript

5
推荐指数
1
解决办法
742
查看次数

标签 统计

applescript ×1