Load Script File

I want to load a external script file like I did in AS Studio.

As an example I have this bit in the applicationWillFinishLaunching_(aNotification) handler…


set LoadedScript to (load script file ((path to desktop as string) & “MyScript.scpt”))
tell LoadedScript to RunScript()

And this in the external script on my desktop


–External script named MyScript.scpt
on RunScript()
display dialog “Here”
end RunScript

This code will work as expected in AppleScript Editor but give this error in ASOC…

2009-11-10 15:02:48.724 Retriever[7381:a0f] *** -[RetrieverAppDelegate applicationWillFinishLaunching:]: Can’t make current application into type file. (error -1700)

I figured it out and it seems to work by changing the code to this…

set LoadedScript to (load script (((path to desktop as string) & “MyScript.scpt”)) as alias)