I am writing a simple applescript application. In file script1.applescript I have:
global x
set x to 1
I would then like to pass the variable x to script2.applescript so that I can utilise whatever it has stored in it in another script. Another way in which I could achive my aim is to excecute a procedure from script2.applescript from script1.applescript, e.g: script2.applescript contains;
script x
-- processes to carry out
end script
script y
-- process to carry out
end script
I would like to excecute ‘script y’ from script1.applescript.
on run p – a list
try
set {v} to p – error if the list is empty
display dialog v
end try
return p
end run
You can run it using ‘run script’:
global x
on clicked theObject
set x to 1
set u_path to (path for script “script2”)
set as_ref to (u_path as POSIX file) as alias
set r to (run script as_ref with parameters {x})
log r
end clicked
parameters are always passed as list. Some other ways is to use ‘load script’ (loads library of subroutines), ‘osascript’ (unix, no parameters unless you use a workaround with ‘run script’ in the unix command). That’s all I can think of right now. I seem to remember that there was something in AS STudio to run a scirpt, but can’t remember.