【发布时间】:2012-05-29 13:50:00
【问题描述】:
如何将全局变量从一个 AppleScript 文件导入到另一个?
我正在使用两个 AppleScript 文件为项目课程创建演示。
一个 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
从这个文件执行时,这工作正常。我想将此文件用作库,其方式类似于 here。我的第二个 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。”编号 -2753 从 “一些目录”
如何将此变量导入我的第二个 AppleScript 文件?
【问题讨论】:
标签: applescript