Re: Setting TextEdit Insertion point
Re: Setting TextEdit Insertion point
- Subject: Re: Setting TextEdit Insertion point
- From: Bill Briggs <email@hidden>
- Date: Sat, 14 Jul 2007 01:12:05 -0300
At 9:22 PM -0600 7/13/07, Ken G. Brown wrote:
>I'm trying to use Applescript to tell TextEdit to open a file, and insert a date/time stamp at the beginning of the file in front of the previous text, followed by two blank lines, then put the insertion point at the beginning of the first blank line so the user can add text at the beginning of a file followed by a blank line. The insertion point always ends up at the end of the file.
>
>This almost does what I want but I do not know how to position the insertion point to where I need it.
>
>set myFile to "MacHD:Testfile.txt"
>tell application "TextEdit"
> activate
> open (file named myFile)
> set myTimeStamp to current date
> tell document 1
> set text 1 to (("-- " & myTimeStamp as string) & " --" & return & return & return) & (text 1)
> end tell
>end tell
>
>Any tips appreciated...
First bit of advice: use a better text editor, like Tex-Edit Plus, BBEdit, or Text Wrangler. TextEdit is a heap of steaming dingo droppings to script. It has no insertion point in the dictionary, and a boat load of other deficits in comparison to the others. Download Tex-Edit Plus (you don't HAVE to pay for it). This script will do what you want.
set myTimeStamp to ((get current date) as string)
tell application "Tex-Edit Plus"
activate
make new document
tell document 1
set contents to ("-- " & myTimeStamp & " --" & return & return)
select insertion point before line 2
end tell
end tell
- web
_______________________________________________
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