new to apple script a simple question

how can i create a text file at desktop using apple script?

my code

tell application "TextEdit"

make new document at desktop

end tell

error "“TextEdit”遇到一个错误:不能将“desktop”转换为“location reference”类型。" number -1700 from desktop to location reference

what's location reference?

how can i fix this problem?

thank you

In this case the location reference tells TextEdit where to put the doc relative to other open docs. To create a new document and save it to a specific location, you can do this.

set destFile to (POSIX path of (path to desktop) & "Test Format.rtf") as POSIX file 
tell application "TextEdit"
    set newDoc to make new document
    save newDoc in destFile
end tell

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
new to apple script a simple question
 
 
Q