3

AppleScript では、別のスクリプトで定義された変数を使用できますか? 次のようなものがあると思います:

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

しかし、特定の変数をどのように選択しますか?

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 に答える