从另一个脚本获取变量

从另一个脚本获取变量

本文介绍了从另一个脚本获取变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

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

You could use property variables in your external script

例如a.scpt:

property foo : "hello world"

...并且在调用脚本中使用" x of n "样式进行引用.

...and in the calling script you use the "x of n" style of referencing.

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

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

You can also access the returned result of a handler in the external script.

例如a.scpt:

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

...并在调用脚本中:

...and in the calling script:

set choice to getChoice() of test

这篇关于从另一个脚本获取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:38