problem with text service actually working

Alright, I am trying to debug a Text Service in Automator. I have simplified it to this.

  1. In Automator, create a New Service.
  2. Make it a text service in any Application.
  3. Add a Run Applescript Action.
  4. Populate it with the following:

on run {input, parameters}
	set newString to "blah"
	return newString
end run

Running this from within Automator generates the usual warning, then runs and show a result of “blah”, as expected.

I then:

  1. Save the service with a name of “blah”.
  2. Head on over to Text Edit.
  3. Select some Text.
  4. Invoke the “blah” Service.

Results: Nothing happens.
Expected: The selected text changes to “blah”.

Not surprisingly, the same results happen changing the Applescript to:

on run {input, parameters}
	set input to "blah"
	return input
end run

Someone see something, anything wrong with what I have done?


This works for me, when I check off “replaces selected text”, on top of the service, where you choose what the service should do.

I am running Snow Leopard

Damn! I hate it when the solution is so simple! :lol: What a waste on time on my part!

Thanks for steering me straight, McUsrII.


The most important thing is trying, the second is not giving up.

Things like that happens to most of us from time to time. :wink:

Happy Scripting.

By the way, Auomator services are hard to debug Applescripts in,

This handler makes it easier, the second parameter is like “ThisService” which becomes a file “ThisService.Log” in ~/Library/Logs (YourHomeFolder:Library:logs:ThisService.log). When you double click that file, it will open up in Console app, and from then onwards, you can watch what happens in your service. call it with “my logit(param1,param2)”.

(Test it in a regular Applescript first, so you see how it works.)

to logit(log_string, log_file)
	do shell script ¬
		"echo `date '+%Y-%m-%d %T: '`\"" & log_string & ¬
		"\" >> $HOME/Library/Logs/" & log_file & ".log"
end logit

Thanks for the input. Obviously, my script I actually did use turned out to be more in depth than what I posted here.

I debug in AppleScript Debugger: Great product BTW.

I made an on Runner with the same parameters as on run. I then called Runner with the parameters I wanted to use.