ある AppleScript ファイルから別の AppleScript ファイルにグローバル変数をインポートするにはどうすればよいですか?
プロジェクトコースのデモを作成するために、2 つの AppleScript ファイルを使用しています。
1 つの AppleScript ファイル「main.scpt」がグローバル変数で始まる
global someDirectory
set someDirectory to "~/Documents/cs123-drj/demo"
on openServerWindow()
# Open the server
tell application "System Events" to keystroke "n" using command down
tell application "System Events" to keystroke "i" using {command down, shift down}
typeKeys("server")
typeKeys(return)
tell application "System Events" to keystroke "i" using command down
typeKeys("cd ")
typeKeys(someDirectory)
typeKeys(return)
typeKeys("./cs123-server.sh")
typeKeys(return)
end openServerWindow
これは、このファイルから実行すると正常に機能します。ここにあるものと同様の方法で、このファイルをライブラリとして使用したいと思います。私の 2 番目の AppleScript の全文は次のとおりです。
#
# Demo script for doing simultaneous selects from a CS123-DRJ database.
#
property CS123Commands : load script POSIX file "/Users/admin/Documents/cs123-drj/demo/main.scpt"
tell CS123Commands to openServerWindow()
このコードを実行しようとすると、次のエラーが発生します。
エラー「変数 someDirectory が定義されていません。」「someDirectory」からの番号 -2753
この変数を 2 番目の AppleScript ファイルにインポートするにはどうすればよいですか?