"to" handler call within tell block


I found the great thread about changing text case. It looks like it’ll be very very helpful for me. Learning how it works will improve my AppleScripting tremendously. For now, I’m trying to learn how to use it. :slight_smile:

The command goes:

changeCase of someText to “sentence”

It works great though if I try to use it in a tell block, I get an error, in this case, "iTunes got an error “the contents of the string.” doesn’t understand the changeCase message. I’ve tried variations (set var to changeCase…, my changeCase …).

Trying to find out about how to statements is crazy. Googling “applescript ‘to sentence’” or any variation. :confused: All I could find out about it is a short mention in the definitive guide saying to is a synonym for on.

Such a basic thing! Hope someone can help. Thanks.


That’s interesting, Gary. The problem seems to be caused by the direct parameter ‘of’ being interpreted (within an application tell statement) as some kind of reference - rather than a parameter (looks like a bit of a bug). A few workarounds spring to mind:

1) Change the direct parameter to an indirect one. This amounts to simply changing the parameter label (both in the calling statement and the handler) to something like:

my (changeCase from someText to "sentence")
my (changeCase for someText to "sentence")
my (changeCase at someText to "sentence")

2) Use the ‘tell me’ form, rather than ‘my’, to make sure the entire statement is redirected to the script:

tell me to changeCase of someText to "sentence"

Or (if you’re setting a variable):

tell me to set some_variable to changeCase of someText to "sentence"

3) Use positional parameters instead of labeled ones - by changing the handler’s header from:

to changeCase of t to c


to changeCase(t, c)

Then use the calling statement:

my changeCase(someText, "sentence")

Many many thanks kai.

I was using your solution 3 until you replied. Since I know what this is all called (labeled parameters), it’s very very interesting reading.

Until less than a month ago I was happy using Doug’s Applescripts for iTunes with a few mods here and there. And then I wanted a script to export iTunes track info to or update info from sql. Since then I’ve been really trying to automate everything I can think of with AppleScript. I’m loving it. AppleScripting is so much fun