I wrote a short script to do a word count in TextEdit, and I found a curious bug. (I know there are existing applications out there. I was trying to update the AppleScript included with NanoCount to be simpler and work with Leopard and learn AppleScript while I was at it.) I'd like someone to tell me if there's something I'm missing, or if this is just something I need to send into a bug report.
The basic structure of the AppleScript looked like this:
There are a couple of syntax variations that work just as well, but this one gets the job done. Unless I have a number followed immediately by a period or a comma.
This sentence will count as 9 words:
I have turned 10 and the day is glorious.
And so will this one:
I have turned ten, and the day is glorious.
But this one will count as 4 (it stops counting words when it gets to 10, )
Today I turned 10, and the day is glorious.
(Please ignore the lameness of my example sentences.)
A number by itself doesn't disrupt the counting, and other punctuation like a semicolon or exclamation point doesn't cause the odd behavior.
Has anyone seen anything like this before? Is there a good workaround other than handing the work off to a unix command and returning the results? I just found this behavior totally bizarre.
The basic structure of the AppleScript looked like this:
Code:
if application "TextEdit" is running then
tell application "TextEdit"
count words of the front document
end tell
end if
There are a couple of syntax variations that work just as well, but this one gets the job done. Unless I have a number followed immediately by a period or a comma.
This sentence will count as 9 words:
I have turned 10 and the day is glorious.
And so will this one:
I have turned ten, and the day is glorious.
But this one will count as 4 (it stops counting words when it gets to 10, )
Today I turned 10, and the day is glorious.
(Please ignore the lameness of my example sentences.)
A number by itself doesn't disrupt the counting, and other punctuation like a semicolon or exclamation point doesn't cause the odd behavior.
Has anyone seen anything like this before? Is there a good workaround other than handing the work off to a unix command and returning the results? I just found this behavior totally bizarre.