从另一个脚本获取变量

时间:2013-09-03 08:33:44

标签: variables applescript

在applescript中你可以使用另一个脚本中定义的变量吗? 我想你会有类似的东西:

set test to (load script "/tmp/a.scpt")

但是你会如何选择一个特定的变量呢?

1 个答案:

答案 0 :(得分:6)

您可以在外部脚本中使用属性变量

例如,a.scpt:

property foo : "hello world"

...在调用脚本中,您使用“ x of n ”样式的引用。

set test to (load script "/tmp/a.scpt")
display dialog (the foo of test)

您还可以在外部脚本中访问处理程序的返回结果。

e.g, a.scpt:

on getChoice()
    set res to choose from list {"one fish", "two fish", "red fish", "blue fish"}
    return res
end getChoice

...并在调用脚本中:

set choice to getChoice() of test
相关问题