2006-01-22 - Brian Theado - in a private email, James LaRue asked me (among other things) about getting the word count of an outline. Here is some code that can be placed in your startup script (Edit->Edit Startup Script) to accomplish this.
proc wordCount tree {
# Accumulate all titles into a list, one title per list item
set titles {}
$tree walk root n {
if {[$tree keyexists $n title]} {
lappend titles [$tree set $n title]
}
}
# Join titles into a single string, condense multiple whitespace chars,
# then split on whitespace and count result
return [llength [split [regsub -all {\s+} [join $titles] { }]]]
}
# Control-Shift-w
bind Outline <Control-W> [namespace code {
::outlinewidget::showConsole
puts "[wordCount [[winfo parent %W] treecmd]] words"
}]Pressing the Control-Shift-w key combination will open the console window and display the number of words in the current outline.
2006-01-23 - Brian Theado - I fixed a problem with displaying the console on unix and I fixed the problem with multiple consecutive whitespace characters inflating the word count.
| Updated 24 Jan 2007, 02:57 GMT Search - Recent Changes - Reference - About WiKit - Go to Tkoutline - Help |