How to tell script editor to save a new file

hi!

how can i tell Script Editor to save a new file with a specified content on a specific place of the disk?

to ask for the specified place on the disk i know that i can do:
set target_folder to (choose folder with prompt “Where do you want to save your AppleScripts?”) as string

to create a nex document in script editor with a specified content i know that i can do:
tell application “Script Editor”
set newdoc to make new document at end with properties ¬
{contents:(“bla bla bla”)}
end tell

BUT I DON’T KNOW HOW TO TELL APPLESCRIPT TO TELL “Script Editor” TO SAVE THIS NEW DOCUMENT TO THE SPECIFIED PLACE…

HELP!!!

If you need simple compiled scripts from a text string, you can try this, which is very quick!

set theScript to "beep 5"

set fileLocation to (choose file name) as string

--> compile the script
set compiledScript to (run script "return my foo" & return & ¬
	"script foo" & return & ¬
	theScript & return & ¬
	"end script")

store script compiledScript in fileLocation replacing yes

If you need applets/droplets, you can follow the same process, but with some variations:
→ create an applet. create a droplet. remember its paths.
→ when you get from user input the variable “fileLocation”, simply check wheter the script-string is an applet/droplet (search for the “open handler”). Eg:

if theScript starts with "on open " or theScript contains (return & "on open ") then
     set thisIsADroplet to true
else
     set thisIsADroplet to false
end if

→ so, if it is a droplet, duplicate your droplet (or applet, if it is an applet) to the user-specified location, so the script is stored within such droplet/applet.

About your original question… (sorry, I don’t know)