counting words

Word processors are written by programmers but used by writers. There are two things that show this in the case of OO. It has a command to select words by the line — which is a syntactic unit in programming and some forms of poetry. but completely arbitrary in prose — but no command to select by paragraph, which is a meaningful unit of prose. And it has its word count buried.

So when I started playing with it, I first made a document field that counted the number of words. This was unsatisfactory, as it would scroll off screen. Then I discovered how to write a simple dialogue box that showed a word count.


Finally, I discovered a macro written years ago that would count words in a selection as well. So I added all these together, and ended up with a single box that would show the word count for a whole document, or a selection.

Then someone called Daniel Vogelheim, who knows what he is doing, wrote to me in early May pointing out that the selected word count was sometimes inaccurate and proposing improvements. I felt this was rather rude of him. Surely it is enough of an improvement to get the damn thing to display any number at all without being picky about whether it is the right one? Also, I can spell separator. which the man who wrote the original code could not. Than should count for something.

In any case, he rewrote my macro so that it counted words accurately in selections as well as in the body of the text. He also made the code look professional: I know that variables should be named so their type is obvious, but this suggests to me that a string I dislike should be called “snot”, and from there it is a natural step to naming another string variable “drool”. You will not find such variables in Mr Vogelheim’s code.

On the other hand, perhaps because he is a programmer, his version counted characters as well as words. This is too much information, as they used to say on the Well. So I had another hack back at his to remove the character counts, and now the result is almost perfect for me. The ability to display both total and selected word counts is wonderful for cutting pieces back to length. If a newspaper wants 700 words, it really doesn’t want 727; now I can see at a glance if the bit I have selected makes a large enough cut. I always write too much and then cut back, and the tighter the deadline, the further over I write.

The Vogelheim version is here. Mine is here.

This entry was posted in Software. Bookmark the permalink.