• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem saving a new file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem saving a new file


  • Subject: Re: Problem saving a new file
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 20 Oct 2012 16:14:54 -0500

Hey Eric,

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.

I also like: Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X

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.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem saving a new file
      • From: Axel Luttgens <email@hidden>
References: 
 >Re: Problem saving a new file (From: Eric Robertson <email@hidden>)

  • Prev by Date: Re: Problem saving a new file
  • Next by Date: Re: Problem saving a new file
  • Previous by thread: Re: Problem saving a new file
  • Next by thread: Re: Problem saving a new file
  • Index(es):
    • Date
    • Thread