Applescript referring to handler breaks script when in "tell.. iTunes"

Hi,

I am using the applescript below to convert all Uppercase characters entered in a input dialog box to lowercase. However, when I enclose the first two lines in "tell application “iTunes/end tell” it breaks the script. I get the error message:

“iTunes got an error: Can’t continue makeCaseLower.”

Could someone help me get this handler working within an iTunes script?

Thanks,

Nick

set theLabel to text returned of (display dialog "Enter label for " with title "Enter Label for Album" default answer "" buttons {"Enter"} default button 1)
	
makeCaseLower(theLabel)
	
end if

on makeCaseLower(theString)
	set UC to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	set LC to "abcdefghijklmnopqrstuvwxyz"
	set C to characters of theString
	repeat with ch in C
		if ch is in LC then set contents of ch to item (offset of ch in UC) of LC
	end repeat
	return C as string
end makeCaseLower

Try:

tell me to makeCaseLower(theLabel)

I would code :


tell application "iTunes"
	tell current application to set theLabel to text returned of (display dialog "Enter label for " with title "Enter Label for Album" default answer "" buttons {"Enter"} default button 1)
	
	my makeCaseLower(theLabel)
	
end tell

on makeCaseLower(theString)
	set UC to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	set LC to "abcdefghijklmnopqrstuvwxyz"
	set C to characters of theString
	repeat with ch in C
		if ch is in LC then set contents of ch to item (offset of ch in UC) of LC
	end repeat
	return C as string
end makeCaseLower

(1) tell current application is used to get rid of error messages issued by every call to OSAX functions from a tell block

(2) the described error message was issued because iTiunes has no idea of what is the makeCaseLower object.
The « tell me to » syntax used by adayzdone is reolving the ambiguity exactly as the shorter « my ».

Yvan KOENIG (VALLAURIS, France) dimanche 6 mai 2012 16:45:55