script within a script

Can an AppleScript be written that opens another script file and then compiles and runs that other script? I tried to record those steps but got nothing.

What would the code look like?

Before you say ‘why would anyone need to do that?’…

I have an application that creates, as one of its outputs, a file with AppleScript code content that can vary with each run (it’s created as a text file). I then want to have that application execute that script. If I have a ‘generic’ script that opens/compiles/runs another script, then I can just have the application run the ‘generic’ script and get the results I need without user intervention.

Hope that makes sense.



This should work:

run script alias "path:to:file.txt"

The code works beautifully. Thanks for your rapid reply!

Tomp :smiley: