textedit

i am trying to say:


tell application "TextEdit"
	activate
                 set allcharacters to every paragraph of document whose name is "textfile.txt"
end tell

and I get an error:

“Can’t get every paragraph of document.”

what am I doing wrong???

also how do I say “bring the document whose name is “textfile.txt” to the front”??

-patrick

TextEdit appears to have a very odd syntax when specifying paragraphs, characters, etc. you need to put an “of it” in the call, such as:

tell application “TextEdit”
activate
tell document “textfile.txt”
set allcharacters to every paragraph of it
end tell
end tell

this worked on my machine.

take care,

Thank you so much!

Just curous-- How do you knonw this? Where do you find this information out??? It it just trial and error, or is there an actual list of syntax for applications outside of the dictionaries?

I just recently have begun going through Hanaan Rosenthal’s AppleScript: A Comprehensive Guide to Scripting and Automation on Mac OS X. A pretty recent book, BTW.

He had a quick example of a TextEdit script that just reversed the paragraphs. I was quick to grab his example. Other than finding it in other people’s answers, or examples, I have no idea where to get this kind of info. There is no real “registry of syntax” for scriptable apps. Maybe that’s a good idea for this site…

take care,