Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'WordService - Add useful text handling to Cocoa apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
WordService - Add useful text handling to Cocoa apps
Authored by: pete.boardman on Feb 03, '05 05:14:19AM
If you want to get into making your own services, investigate Bellhop (xendai.com). Here's a Count Words in Selection (using spaces as delimiters) written for use with Bellhop and Growl. (I like Growl's unobtrusive display.)

on runService (aPasteboard)
	set theText to readPasteboardString(aPasteboard, NSStringPboardType)
	set theWordCount to countWords(theText)
	tell application "GrowlHelperApp" 
	notify with title "Words in selection" description theWordCount  icon of application "Bellhop" with sticky
	end
end runService

to countWords(s)
	set oldTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to " "
	set theCount to count the text items of s
	set AppleScript's text item delimiters to oldTID
	return theCount as string
end


[ Reply to This | # ]