Re: TextEdit AppleScript bug
Re: TextEdit AppleScript bug
- Subject: Re: TextEdit AppleScript bug
- From: Chuck Soper <email@hidden>
- Date: Sun, 20 Oct 2002 12:30:59 -0700
I know this is an old thread, but I'm trying to figure out how I can write a
script to open a file in TextEdit as UTF-8. To do this in TextEdit I have to
select "Unicode (UTF-8)" the "Plain Text Encoding" menu and "Unicode
(UTF-8)" must already be in my Encodings List.
I can open the file with the following script (as John Delacour explained in
the email below):
set f to "'/tmp/temp.txt'"
do shell script "open -a 'TextEdit' " & f
But, is there a way to specify "UTF-8" as I would do with the open dialog?
Also, if this is possible, how would I have looked up the answer on my own?
The default text encodings for open and save are specified in the TextEdit
Preferences.
Thanks,
Chuck
On 10/15/02 6:18 AM, "John Delacour" <email@hidden> wrote:
>
At 7:03 am -0400 15/10/02, Bill Cheeseman wrote:
>
>
> James Hober reported to me that 'close front window saving yes' no longer
>
> works correctly in TextEdit under Mac OS X 10.2 (Jaguar). It closes the
>
> window, but it doesn't save changes to the file (whether the file has been
>
> previously saved or not).
>
>
>
> I get the same problem. Does this work for anybody?
>
>
If I use that syntax with an document that has unsaved changes, I get
>
a dialog whether I like it or not. The window does not close unless
>
I answer.
>
>
Instead I would use this, which does work:
>
>
>
tell app "TextEdit"
>
tell front document
>
save in path
>
close
>
end
>
end
>
>
>
'path' in TextEdit is the POSIX path and it's good to see that it
>
does not need to be converted to anything else in this case. Pity to
>
see that the syntax
>
>
tell app "TextEdit" to open "POSIX/pathname"
>
>
does not work. Instead, to be consistent, you'd have to write
>
>
set f to "'/tmp/temp.txt'"
>
do shell script "open -a 'TextEdit' " & f
>
>
>
JD
>
>
>
set f to "/tmp/temp.txt"
>
do shell script "perl -e '
>
$f = q~" & f & "~ ; open F, qq~>>$f~ ; `open $f`;'"
>
tell app "TextEdit"
>
tell front document
>
set its text to "hello"
>
save in its path
>
close
>
end
>
end
>
do shell script "open -a 'TextEdit' " & quoted form of f
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.