The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Word Count Revisited Thread Tools Search this Thread Display Modes
Quote:
Originally Posted by RobTrew View Post
Both working fine with my files under OS X 10.5.5 and OO 3.7.2

How are you running them ?
For me that's the same config.
 
Quote:
Originally Posted by RobTrew View Post
Both working fine with my files under OS X 10.5.5 and OO 3.7.2

How are you running them ?
Both from script editor and from the script menu. I haven't tried it with 10.5.5 yet. Perhaps that is the essential difference? Hard to see why it should be, but...
 
And it works fine in 10.5.5. Interesting. Well, time to file a bug report, I guess.
 
In the meanwhile I have redrafted both scripts to make them work under OS X 10.4.11

(It looks as if something may have slipped between cup and lip in the Omni-implementation of the text collection of the cell object - there is some Applescript slippage between "text" and "texts" at work here)

Wordcount

Code:
tell application "OmniOutliner Professional"
	set intWords to 0
	set intTexts to 0
	set iText to 0
	
	tell front document
		repeat with oRow in rows
			repeat with oCell in cells of oRow
				if type of column of oCell is rich text then
					set intTexts to count of text of oCell
					repeat with iText from 1 to intTexts
						set intWords to intWords + (count of words of text iText of oCell)
					end repeat
				end if
			end repeat
		end repeat
	end tell
	
	display dialog (intWords as string) & " words"
end tell
Character Count

Code:
tell application "OmniOutliner Professional"
	set intChars to 0
	set intTexts to 0
	set iText to 0
	
	tell front document
		repeat with oRow in rows
			repeat with oCell in cells of oRow
				if type of column of oCell is rich text then
					set intTexts to count of text of oCell
					repeat with iText from 1 to intTexts
						set intChars to intChars + (count of characters of text iText of oCell)
					end repeat
				end if
			end repeat
		end repeat
	end tell
	
	display dialog (intChars as string) & " characters"
end tell

Last edited by RobTrew; 2008-11-30 at 12:00 PM..
 
Hi
Thanks again
For me (leopard 10.5.5 .oo3 version 3.7.2)
Word count : both version works
Character count : only the first one works, see below
Quote:
tell application "OmniOutliner Professional"
set intChars to 0

tell front document
repeat with oRow in rows
repeat with oCell in cells of oRow
if type of column of oCell is rich text then
repeat with oText in text of oCell
set intChars to intChars + (count of characters of oText)
end repeat
end if
end repeat
end repeat
end tell

display dialog (intChars as string) & " characters"
end tell
Regards
 
Thanks - there was a typo on the second version of the character counter.

I have corrected it above, and it should now work under all versions of OS X
 
Quote:
Originally Posted by RobTrew View Post
One can of course get a rough word count (without any great speed) through the Applescript interface ...
Thank you, I'm going to check this out.
 
Just had to make a rough of count some words in a hurry this morning.

For what its worth, I am now using a simpler applescript to do this, which may run a little faster.

It gives 3 word counts:
  1. Whole document
  2. Visible rows
  3. Selected rows

Code:
-- Ver 0.6
-- If value of following property is edited to true,
-- then total word count will be placed in clipboard
property pToClipboard : true
property pDelim : space
property pEOL : return & return


tell application id "com.omnigroup.OmniOutlinerPro3"
	try
		activate
		set oDoc to front document
	on error
		return
	end try
	
	-- Ensure that text item delimiter is SPACE
	-- and prepare to restore any other value at the end of the script
	set strDelim to my text item delimiters
	set my text item delimiters to pDelim
	
	tell front document
		
		set lstAllTopics to topic of rows
		set lstVisblTopics to topic of rows where visible is true
		set lstSeldTopics to topic of selected rows
		
		-- Count total, visible, and selected rows
		set intAllRows to count of lstAllTopics
		set intVisblRows to count of lstVisblTopics
		set intSeldRows to count of lstSeldTopics
		
		-- Count words in all, visible, and selected rows
		set intAllWords to count of words of (lstAllTopics as text)
		if intVisblRows is not equal to intAllRows then
			set blnAllVisible to false
			set intVisblWords to count of words of (lstVisblTopics as text)
		else
			set blnAllVisible to true
			set intVisblWords to intAllWords
		end if
		if intSeldRows is not equal to intAllRows then
			set blnAllSeld to false
			set intSeldRowWords to count of words of (lstSeldTopics as text)
		else
			set blnAllSeld to true
			set intSeldRowWords to intAllWords
		end if
	end tell
end tell

-- Prepare report to user
set strMsg to (intAllWords as text) & pl(intAllWords, "word") & " in total   (" & (intAllRows as text) & pl(intAllRows, "row") & ")" & pEOL
if not blnAllVisible then set strMsg to strMsg & 
	(intVisblWords as text) & pl(intVisblWords, "word") & " in " & (intVisblRows as text) & " visible" & pl(intVisblRows, "row") & ")" & pEOL
if not blnAllSeld then
	set strMsg to strMsg & 
		(intSeldRowWords as text) & pl(intSeldRowWords, "word") & " in " & (intSeldRows as text) & " selected" & pl(intSeldRows, "row")
end if
try
	display dialog strMsg with icon 1 with title ("WORD COUNT")
end try

set my text item delimiters to strDelim
if pToClipboard then 
	tell application id "com.apple.finder" to set the clipboard to (intAllWords as text)

-- Pluralize word unless lngQuant is 1
on pl(lngQuant, strWord)
	if lngQuant is 1 then return " " & strWord
	" " & strWord & "s"
end pl

--

Last edited by RobTrew; 2010-06-25 at 05:32 AM.. Reason: ver 0.6 Minor edits and improvements in reporting
 
Or, for a short, no-nonsense word count:

Code:
set strDelim to text item delimiters
set text item delimiters to space
tell front document of application "OmniOutliner Professional"
	try
		display dialog (count of words of ((topic of rows) as text)) as text
	end try
end tell
set text item delimiters to strDelim
--

Last edited by RobTrew; 2010-04-23 at 06:37 AM.. Reason: attend to text item delimiters
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
OmniGraffle Word Count RobTrew OmniGraffle General 2 2010-10-04 01:48 PM
Checklists, revisited Arild OmniFocus 1 for Mac 5 2010-06-08 07:26 AM
Word Count and Statistics Patrick J OmniOutliner 3 for Mac 7 2009-04-20 10:50 PM
Word Count Patrick J OmniOutliner 3 for Mac 0 2007-10-20 09:40 AM
Word Count m_s OmniOutliner 3 for Mac 0 2006-10-25 03:49 AM


All times are GMT -8. The time now is 12:07 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.