• 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: Scripting TextEdit, round II
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting TextEdit, round II


  • Subject: Re: Scripting TextEdit, round II
  • From: kai <email@hidden>
  • Date: Sat, 13 May 2006 00:49:29 +0100


On 12 May 2006, at 18:09, Nelson Byrne wrote:

OK, I think I'm getting it. Thanks for all the help; this is a great list.
You all told me "references, references, references" and you were right. This works:


-------------------------
property hitlist : {"MANNY", "MOE", "JACK"}

tell application "TextEdit"
get item 1 of (get documents whose name contains "PEP") returning theDoc
tell theDoc to get words of theDoc returning theWords
end tell


considering case
	repeat with i from 1 to number of items in theWords
		if item i of theWords is in hitlist then
			(a reference to word i of theDoc) returning wordref
			set size of first character of wordref to 24
			set font of wordref to "Palatino Bold"
		end if
	end repeat
end considering
-------------------------

Excellent stuff, Nelson. As you've clearly gathered, it's necessary to iterate through a repeat loop for this, because the considering statement affects the way in which AppleScript (rather than TextEdit) compares the words in 'theWords' with those in 'hitlist'.


I was going to post the following suggestion earlier, and was delighted to see your solution. For comparison, I've inserted the same variable labels and comparison criteria. Minor syntax differences aside, the scripts do exactly the same thing. :-)

--------
property hitlist : {"MANNY", "MOE", "JACK"}
tell application "TextEdit" to tell (get first document ¬
	whose name contains "PEP") to considering case
	set theWords to words
	repeat with i from 1 to count theWords
		if item i of theWords is in hitlist then tell word i
			set character 1's size to 24
			set font to "Palatino-Bold"
		end tell
	end repeat
end considering
--------

---
kai


_______________________________________________ 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
References: 
 >Re: Scripting TextEdit, round II (From: Nelson Byrne <email@hidden>)

  • Prev by Date: Mysterious Preferences File Again
  • Next by Date: Re: Resizing image in image events
  • Previous by thread: Re: Scripting TextEdit, round II
  • Next by thread: ADG2
  • Index(es):
    • Date
    • Thread