首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何读取通过引用传递的值的属性?

如何读取通过引用传递的值的属性?
EN

Stack Overflow用户
提问于 2014-09-16 18:59:33
回答 1查看 183关注 0票数 0

我正在尝试编写OmniGraffle 5.3.6脚本,尝试读取传递给函数(或处理程序,用AppleScript术语)的canvaslayers元素。当我运行以下命令时:

代码语言:javascript
复制
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

我得到以下错误:

代码语言:javascript
复制
  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

但是,如果我要内联我的函数,那么一切都很好:

代码语言:javascript
复制
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

我读过引用传递与值传递,但没有发现它有什么用。很稀疏。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-17 14:14:34

你可以参考通过。但是,无论您传递到哪里,它也必须有"tell application“,以便应用程序能够处理传递的引用。所以你会想要这样的功能..。

代码语言:javascript
复制
on exportToPng(theCanvas)
    tell application "OmniGraffle Professional 5"
      set layerCount to count of layers of theCanvas
    end tell
end exportToPng

毕竟,只有"OmniGraffle专业5“知道如何从theCanvas中获取层。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25876467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档