Re: Scripting TextEdit
Re: Scripting TextEdit
- Subject: Re: Scripting TextEdit
- From: Matt Neuburg <email@hidden>
- Date: Sun, 07 May 2006 09:31:06 -0700
- Thread-topic: Scripting TextEdit
On Fri, 5 May 2006 17:39:24 -0700, Nelson Byrne <email@hidden> said:
>What's wrong with this?
>
>tell application "TextEdit"
> get front document returning theDoc
> tell theDoc
> get text of theDoc returning theText -->"Recitative"
> font of theText -->"Can't get font of \"Recitative\"."
> end tell
>end tell
In TextEdit's world, texts have fonts. As long as you're talking about
TextEdit's text, and not a copy that you've retrieved, the text has a font.
Once you have *retrieved* the text, however, you've got a string (actually a
Unicode text), and a string has no font. So what you want to do is, as it
were, leave TextEdit in possession of the text. So, say this:
tell application "TextEdit"
get front document returning theDoc
tell theDoc
font of its text
end tell
end tell
A way to do this in two steps, as in your original script, would have been
to insist upon a reference:
tell application "TextEdit"
get front document returning theDoc
tell theDoc
get a reference to its text returning theText
font of theText
end tell
end tell
See chapter 12 ("References") of you-know-what (and p. 190 on the perils of
"get"). m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden