• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting TextEdit Insertion point
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Setting TextEdit Insertion point
      • From: Bill Briggs <email@hidden>
References: 
 >Setting TextEdit Insertion point (From: "Ken G. Brown" <email@hidden>)

  • Prev by Date: Setting TextEdit Insertion point
  • Next by Date: Re: Setting TextEdit Insertion point
  • Previous by thread: Setting TextEdit Insertion point
  • Next by thread: Re: Setting TextEdit Insertion point
  • Index(es):
    • Date
    • Thread