unable to save .scpt file

Hi,
i created an applescript-file using a text-routine and now this *.scpt isn’t executable, the creator is set naturally to “TEXT” instead to “ToYs”. I tried to change the Creator’s Type, but this changed nothing.
I’m able to open and run this file when open in Applescript Editor but without the possibility to save it. Executing this one from a script does not work, like: “run script file”.
i tried to save the script as common *scpt file, using:

tell application Appscr_app to save create_plug in inputFile as "osas" 

but this (lousy) command writes to nowhere, if the front window does not contain the script to save to disk. Suggestions?

Hi,

AppleScript Editor provides its own save command, but you have to wrap the code in a real AppleScript Editor tell block. Tell blocks with a non-literal application specifier cannot resolve the specific terminology.


tell application "AppleScript Editor" to save create_plug in inputFile as "script" 

Hi,
i’m here on Lion and things are slightly different as on M. Lion, i assume.
my script continues to not work. Here an example:

set inputFile to POSIX path of ((path to desktop folder as text) & "test.scpt" as text)
set create_plug to "tell application \"iCal\" to activate"

tell application "AppleScript Editor" to save create_plug in quoted form of inputFile as "osas"

Hello.

Unless you are totally fastidious about using AppleScript Editor, have you considered osacompile for creating the plug in ? ( man osacompile ).

hth

AppleScript Editor is document based.
You have to create a new document, put the text in, compile and save


set inputFile to (path to desktop folder as text) & "test.scpt"
set create_plug to "tell application \"iCal\" to activate"

tell application "AppleScript Editor"
	make new document with properties {contents:create_plug}
	tell document 1
		compile
		save in file inputFile as "script"
	end tell
end tell

for a faceless progress I recommend osacompile like McUsr

Hi,
Stefan, thanks for the tip. I thought maybe some features aren’t available on my actual Os. I tried with :

set code_sc to paragraphs of "tell application \"iCal\"" & return & "activate" & return & "end tell"
set res to {}
repeat with a in code_sc
	copy ("-e " & "'" & a & "'" & space as text) to end of res
end repeat
set res to res as text
#return res
set inputf to (path to desktop folder as text) & "test.scpt"
do shell script "osacompile -t osas -c ToyS " & res & " -o '" & POSIX path of inputf & "'"

(testing with multiple lines). This works, but not always for reasons related to strange characters and quotes.
i also tried with the “load script-store script” commands but these work only with compiled contents OR a selected file

less complicated, with the prefix -e $ you can pass the complete source text


set code_sc to "-e $" & quoted form of ("tell application \"iCal\"" & return & "activate" & return & "end")
set inputf to (path to desktop folder as text) & "test.scpt"
do shell script "osacompile -o " & quoted form of POSIX path of inputf & space & code_sc