Dynamic creation of an AppleScript via AppleScript


Markus Ruggiero
 

Hi,

I want to create an AppleScript .scpt file programmatically without using Script Editor. The goal is to have some Apple Script commands in a plain text file to be used as a template. I want to create an AppleScript that should ask the user a couple questions and then use the answers to fill in the "template" and finally save the resulting script to disk.

Simplified example:

Template.txt contains

set theApplication to XXXXX
tell application theApplication
-- many things....
end tell

My script should ask the user for the name of the application, then load the template and replace XXXXX by what the user has given. At the end the result should become a .scpt file on disk.

Thanks for any help
---markus---

Join applescript@apple-dev.groups.io to automatically receive all group messages.