3

In applescript can you use a variable that was defined in another script? I think you would have something like:

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

But how would you pick a specific variable?

4

1 回答 1

5

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

例如,a.scpt:

property foo : "hello world"

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

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

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

例如,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
于 2013-09-03T09:46:49.777 回答