【发布时间】:2017-07-29 09:33:45
【问题描述】:
我有一个从 plist 文件中提取的变量(这是我想出的将变量从一个脚本传递到另一个脚本的最佳方法)
它工作正常,如果我做一个随机的“显示通知 var1”我有正确的结果。
但是,如果我想在函数 ex. 中传递变量。
set var1 to ""
set the plistfile_path to "~/Desktop/_DATA.plist"
tell application "System Events"
set p_list to property list file (plistfile_path)
-- read the plist data
set var1 to value of property list item "DSID" of p_list as text
end tell
[...]
on makeStatusBar()
set bar to current application's NSStatusBar's systemStatusBar
set StatusItem to bar's statusItemWithLength:-1.0
-- set up the initial NSStatusBars title
StatusItem's setTitle:var1
-- set up the initial NSMenu of the statusbar
set newMenu to current application's NSMenu's alloc()'s initWithTitle:"Custom"
newMenu's setDelegate:me (*
Requied delegation for when the Status bar Menu is clicked the menu will use the delegates method (menuNeedsUpdate:(menu)) to run dynamically update.
*)
StatusItem's setMenu:newMenu
end makeStatusBar
我有这个错误
"变量 var1 未定义。变量 var1 未定义。 (-2753)"
我该如何解决这个问题?提前谢谢你。
【问题讨论】:
标签: function variables applescript handler var