I have a variable extracted from a plist file (that the best way I figure out for passing variable from one script to a another)
It's work fine, if I do a random "display notification var1" I have the correct result.
However if I want to pass the variable in a fonction 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
I have this error
"The variable var1 is not defined. The variable var1 is not defined. (-2753)"
How can I fix this? thank you in advance.
var1
is in local scope. Declare it as property:
property var1 : ""
Alternatively declare it as global:
global var1
set var1 to ""
The other variable theDSIDFromPlist
doesn't appear in the code.