On Oct 20, 2012, at 11:30, Eric Robertson <
email@hidden> wrote:
I've written a lot of Perl and _javascript_ and I've found that the cookbooks for these are invaluable for working out how to solve a problem. I've been reading "AppleScript, The Definitive Guide" and "AppleScript 1-2-3" but I couldn't find in either of these a solution to my problem. Do you know of another book that is more in the nature of a cookbook?
The books you cite are two of the better ones.
One thing to consider is that all editions of the Applescript books predate Lion and Mountain Lion.
I don't believe there's an Applescript book out there that's in cookbook format.
I've been following this list for some time now and it seems that very few postings are by newbies like myself. Is it OK for me to post questions like this to this list or is the MacScripter forum a more appropriate place?
Sure it's okay.
We WANT more Applescript users posting on this list and noob questions are quite welcome. :)
Well, this problem sure is a bunch of horse pucky. Apple has made some very inconvenient changes to TE.
This works with TextEdit 1.8 on Mountain Lion. Note that it saves to the Desktop. Trying to save to Documents fails no matter what embedded folder I try.
------------------------------------------------------------------------------------------------
tell application "TextEdit"
set newFile to (((path to desktop folder) & "Test_File.rtf") as text) as «class furl»
set _text to "Here is some sample text."
set newDoc to make new document with properties {text:_text}
save newDoc in newFile
end tell
------------------------------------------------------------------------------------------------
I have 1.8 zipped and use 1.6, because it's waay faster and better behaved.
This works fine with TextEdit 1.6:
------------------------------------------------------------------------------------------------
tell application "TextEdit"
set newFile to (((path to documents folder) & "Test_File.rtf") as text)
set _text to "Here is some sample text."
set newDoc to make new document with properties {text:_text}
save newDoc in newFile
end tell
------------------------------------------------------------------------------------------------
So does this:
------------------------------------------------------------------------------------------------
tell application "TextEdit"
set newFile to "Documents/Test_File.rtf"
set newFile to do shell script "echo ~/" & quoted form of newFile
set _text to "Here is some sample text."
set newDoc to make new document with properties {text:_text}
save newDoc in newFile
end tell
------------------------------------------------------------------------------------------------
Now then. The more serious question is why-in-hell are you using TextEdit? :)
Download
Tex-Edit Plus (inexpensive shareware - demo completely uncrippled and not time-limited) and
TextWrangler (free version of BBEdit) - both are extensively scriptable and well behaved.
Tell us what you actually want to accomplish, and we'll give you better methods than using TextEdit.
TE is not a good app to learn on.