我正在尝试编写OmniGraffle 5.3.6脚本,尝试读取传递给函数(或处理程序,用AppleScript术语)的canvas的layers元素。当我运行以下命令时:
on exportToPng(theCanvas)
set layerCount to count of layers of theCanvas
end exportToPng
tell application "OmniGraffle Professional 5"
set theDocument to front document
set allCanvases to canvases of theDocument
set theCanvas to item 1 of allCanvases
my exportToPng(theCanvas)
end tell我得到以下错误:
error "OmniGraffle Professional 5 got an error: Can’t make |layers| of
canvas id 1 of document \"base-dependency-diagram.graffle\" into type reference."
number -1700 from |layers| of canvas id 1 of document
"base-dependency-diagram.graffle" to reference但是,如果我要内联我的函数,那么一切都很好:
tell application "OmniGraffle Professional 5"
set theDocument to front document
set allCanvases to canvases of theDocument
set theCanvas to item 1 of allCanvases
set layerCount to count of layers of theCanvas
end tell我读过引用传递与值传递,但没有发现它有什么用。很稀疏。
发布于 2014-09-17 14:14:34
你可以参考通过。但是,无论您传递到哪里,它也必须有"tell application“,以便应用程序能够处理传递的引用。所以你会想要这样的功能..。
on exportToPng(theCanvas)
tell application "OmniGraffle Professional 5"
set layerCount to count of layers of theCanvas
end tell
end exportToPng毕竟,只有"OmniGraffle专业5“知道如何从theCanvas中获取层。
https://stackoverflow.com/questions/25876467
复制相似问题