Subroutine help needed

I’ve written a fairly simple subroutine to search a list. The subroutine is:

on mySearchList(needle, haystack)
	repeat with i from 1 to count of haystack
		if needle is equal to item i of haystack then return i
	end repeat
	return 0
end mySearchList

When I try to call the routine (in a tell application “Address Book,” if that matters):

set indx to mySearchList((first name of staff) as string, person_list)

I get the error: “Address Book got an error: Can’t continue mySearchList.” Can anyone see what I’m doing wrong? TIA.

Oh! I didn’t know that. It works now, thanks. :slight_smile:

Otherwise, it is assumed that the handler is to be found in Address Book. For reasons I don’t understand, the “my” isn’t always necessary.