PDA

View Full Version : AppleScript Question




Wallace25
Mar 23, 2007, 07:44 PM
I have an applescript that I can't get to work. I am openening a file with a name of "TestScript", then adding text to it. That part works fine, but then I try to have script editor save it, and it saves as untitled.

Any ideas?

Here is the script

set fileLocation to choose folder
set x to "testText"

tell application "Script Editor"

set newDoc to make new document with properties {name:"TestScript"}


set text of newDoc to x
compile newDoc
save newDoc in fileLocation



xUKHCx
Mar 23, 2007, 08:14 PM
bit of a nasty way of doing it, but this seems to work.

Sure there is probably a better way of doing it.


set fileLocation to choose folder
set x to "testText"
set y to "TestScript"
tell application "Script Editor"

set newDoc to make new document with properties {name:y}


set text of newDoc to x
compile newDoc
save newDoc in fileLocation
tell application "Finder"
set sav to fileLocation & "Untitled.scpt" as string as alias
set name of sav to y & ".scpt" as string
end tell
end tell

lancestraz
Mar 23, 2007, 08:21 PM
Use this.
set fileLocation to (((choose folder) as string) & "testScript")
set x to "testText"

tell application "Script Editor"
set newDoc to make new document with properties {name:"TestScript"}
set text of newDoc to x
compile newDoc
save newDoc in fileLocation
end tell

You can change the text "testScript" in the first line to whatever you want to save it as.

Wallace25
Mar 23, 2007, 09:38 PM
Use this.
set fileLocation to (((choose folder) as string) & "testScript")
set x to "testText"

tell application "Script Editor"
set newDoc to make new document with properties {name:"TestScript"}
set text of newDoc to x
compile newDoc
save newDoc in fileLocation
end tell

You can change the text "testScript" in the first line to whatever you want to save it as.


Thanks works great.