iTunes scripting: Can't continue error on a nahdler

What’s wrong with this?


tell application "iTunes"
	if selection is not {} then
		set songList to a reference to selection
		set songCount to (count of items in songList)
		set threeMore to addThree(songCount)
		display dialog threeMore
	end if
end tell

on addThree(num)
	return num + 3
end addThree

I keep on getting “iTunes got an error: Can’t continue addThree.”

Model: PowerBook G4, iMac G5, MacBook
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4) Gecko/20070509 Camino/1.5
Operating System: Mac OS X (10.4)

Hi,

iTunes has no idea, what a handler is, but AppleScript has, so just add the keyword my

set threeMore to my addThree(songCount)

PS: does your text conversion script work now?

Thanks. Conversion works – I’ve also gotten rid of an extra script, moved property to a top level. The question above is part of the same script, actually.

See also: Scope of Subroutine Calls in Tell Statements

FWIW – here’s the 0.1 release of it: http://code.google.com/p/as-convert-russian/

Great, thanks for being mentioned in the source code :wink: