views:

523

answers:

1

Hi folks,

I am trying to create a service in OSX leopard that counts the number of words of selected text. I have automator set to run an applescript, with the following put in it:

on run {input, parameters}
        count words of input
        display alert "Words: " & input
        return input
end run

When I compile the script, it says it cannot count every word. What am I doing wrong?

Thanks for the help,

Elliott

+2  A: 

First of all, I presume you are testing this in Automator, and that's where the error is taking place? If so, the likely problem is that there is no input—so it can't count the words of nothing. In order to test it successfully, you need to temporarily add a "Get Specified Text" action before the Run AppleScript action, and enter some test text into that field. You'll have to remove the Get Specified Text action before using it as an actual service.

Secondly, you need to use

count words of (input as string)

in order to get a proper count, otherwise it'll return zero.

Jonathan Patt
Thanks for the answer- I had the issue of not using a string, so thanks for clearning that up.
Elliott Bowles