AppleScript: Get record name without suffix

Here’s a handler to get the name without suffix

set theName to my recordName(name of theRecord, filename of theRecord)

on recordName(theName, theFileName)
	set revName to reverse of (characters of theName) as string
	set suffixName to reverse of (characters 1 thru ((character offset of "." in revName) - 1) in revName) as string
	set revFileName to reverse of (characters of theFileName) as string
	set suffixFileName to reverse of (characters 1 thru ((character offset of "." in revFileName) - 1) in revFileName) as string
	if suffixName = suffixFileName then set theName to reverse of (characters ((character offset of "." in revName) + 1) thru -1 in revName) as string
	return theName
end recordName