call script from script

i’ve done a bit of searching but cannot seem to find the syntax or info telling me how to call one applescript from within another. essentially, i have a script that will play a particular iTunes playlist for an alarm in iCal. i have the script to set the system volume as a whole and i have the script working by simply pasting “volume” script at the beginning of each playlist script, but i’d rather simply tell each playlist script to call/reference my volume script. that way i can easily edit the volume script without editing all the playlists script. kind of like a flash movie within a flash movie to make a comparison. any help is appreciated… Pajamation

There are two basic approches. First, if you save your volume script as a script application, then you can treat it like any other application:


tell application "My Volume Script"
    run
end tell

As just a compiled script, you can either use the “load script” command or the “run script” command, (look up their syntax in the Standard Additions dictionary).


set myVolumeScript to load script alias "path:to:volumeScript.scpt"
tell myVolumeScript to run

-- or simply:
run script alias "path:to:volumeScript"

i went back and saved the script as an application but kept getting an error on the “run” command; decided to try the “run script alias” and it worked fine… except for this feedback “thump” sound i get when it finishes and before it starts the itunes portion of the script. not sure why it makes the sound but i suppose i can live with it seeing how it runs now. any thoughts? pajamation

Hi,

When you run a script application, you need to give it the launch command first. Also, if you want to bring the script app that you’re running to the front, then you need to place an activate command at the top of the run handler. For xample, save this as script app as “Dialoghi”:

activate
display dialog “hi”

Now, type this in script editor

tell app “Dialoghi”
launch
run
end tell

The tell line:

tell app “Dialoghi”

executes an implicit run command. The launch command makes it not send this run command.

gl,

that did the trick… thanks so much.

pajamation