Re: Problem saving a new file
Re: Problem saving a new file
- Subject: Re: Problem saving a new file
- From: Eric Robertson <email@hidden>
- Date: Mon, 22 Oct 2012 12:47:31 +0100
On 21 Oct 2012, at 11:49, Axel Luttgens < email@hidden> wrote:
Le 20 oct. 2012 à 17:30, Eric Robertson a écrit :
[...]
I was aware that you can't use a file alias for a non-existent one but I thought I'd read that while the dictionary of some applications specified that a file alias had to be used you could get by without using one. This doesn't work here and I see how you've got over this problem.
Hello Eric,
You are right: dictionaries are often a bit inaccurate when it goes about the way to specify a file; as a result, some trial and error is often needed...
On the other hand, it's always worth to have a look at the way an application behaves, since its scripting model usually tends to reflect that behavior.
In the case of TextEdit, the workflow is to ask for a new document (which is internally handled by TextEdit in some kind of limbo as far as the user is concerned), then to type some contents, and finally to save the document somewhere.
So, let's try to just mimic this:
tell application "TextEdit" tell (make new document) set its text to "This is sample text" close saving in POSIX file "/Users/ericrobertson/Documents/New Notes.rtf" end tell quit end tell
HTH, Axel
Thanks Axel, that works fine. I'm confused though as some of the other suggestions haven't worked because it seems of this sandbox effect, and the new file had to be set up outside of TextEdit yet here you've managed to do the whole thing inside TextEdit. Is it because you've got the whole thing inside that second 'tell' so the whole thing is inside the sandbox?
I don't think I would have thought of this way of writing the script from the workflow.
Eric
PS Sorry I forgot to change the Subject in my last email - any way to change this now? |
_______________________________________________
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