AppleScript – How to Get AppleScript to Open Another Script File

applescriptmacos

So I'm working on a script and I want one of the buttons to open another script file. I have:

    tell application "AppleScript Editor" to open "Fallen_Order_Intro.sctp"

When I do this, it says that it can't open "Fallen_Order_Intro.sctp" because it is a text document, (which it isn't). Am I going about it the wrong way? Is there a different way I should be trying to open a script file? Thank you

Best Answer

You're close.

Get the path to your file by making a one-line script:

set the_file to choose file

Copy the result of that. Then, in the script that will open the "Fallen_Order_Intro" script, tell the Finder to do the opening for you, pasting in your second script's path, obtained using the "choose file" script. Here's how it would look if your "Fallen_Order_Intro" script is on your desktop (and if your user name is sdavis).

tell application "Finder"
    open alias "Macintosh HD:Users:sdavis:Desktop:Fallen_Order_Intro.scpt"
end tell

That's all there is to it. The file will open in Script Editor because the Finder knows it's a Script Editor document.