Re: Insert text into a document (beginners Question)
Re: Insert text into a document (beginners Question)
- Subject: Re: Insert text into a document (beginners Question)
- From: Emmanuel <email@hidden>
- Date: Fri, 12 Dec 2003 20:12:28 +0100
At 9:15 AM -0800 12/12/03, Paul Berkowitz wrote:
>
On 12/12/03 7:56 AM, "Robert Morse" <email@hidden> wrote:
>
>
> Another beginners question.
>
>
>
> Say I have a document loaded into TextEdit, and would like
>
> to insert some text at the current cursor position. How
>
> would I go about that.
>
>
>
> I have found a way to get all the text, found how to get
>
> the "selection point", but this gives me something like
>
> "Selection at character position 34 of file bla", which
>
> is really not what I think I need.
>
>
>
> If anyone can just do a small snippet on how to do it
>
> it would be great. I have the "Applescript in a nut
>
> shell" and got on order the other "O'Reilly" book, but
>
> that will take some time to arrive.
>
>
You can't possibly really mean TextEdit, can you? It doesn't have anything
>
to do with selection in its dictionary. Do you mean Tex-Edit Plus? Its terms
>
are exactly those you mention. If not, you should get Tex-Edit Plus
>
immediately. Its scriptability is a model of AppleScript implementation,
>
whereas TextEdit's scripting is junk. Which is unfortunate, since the app
>
itself is very good. Never mind. In Tex-Edit what you want is really simple
>
to do.
>
>
>
tell application "Tex-Edit Plus"
>
set selection to (return & return & "I'm now inserting a new paragraph
>
at this point." & return & return)
>
end tell
>
>
>
>
If you don't want it to be a new paragraph just leave out the 'returns':
>
>
tell application "Tex-Edit Plus"
>
set selection to "I'm now inserting a new sentence. "
>
end tell
An option could be also to use Smile: it's both a script editor and a scriptable text editor. You would write:
----------------
set selection of window 2 to "I'm now inserting a new sentence"
----------------
(you don't need the "tell" instruction, since you're in Smile).
Emmanuel
_______________________________________________
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.