Problem using subroutine inside tell block

Hello,

I’m new to this forum and new to applescript.

I’m trying to create a little script which has a sub function to be called. It’s looking a bit like this.

tell application "ical"
	set temp to subfun(test)
end tell

on subfun (something)
	return ans
end temp

So whenever I run the script it complains that iCal does not know how to do subfun. How can I call this subfun from inside a tell? Thanks for the help.

I you use the handler call inside a tell block, the targeted application is searching for that function and can’t find it, because it’s not a function of the application but it’s a function of the script.

So you have to use the word ‘my’.

tell application "iCal"
	set temp to my subfun(test)
end tell

Thanks very much. I might have know it was something easy like that!