AppleScript compiles in ScriptEditor, Not Hazel

Before I spend a lot of time trying to make it work, I just thought I'd run this past the group to see if I just shouldn't bother. I've got an applescript that makes use of an subroutine from Apple to replace text strings. I've used this in conjunction with Hazel for over a year as an external script, and was giddy with delight at the thought of being able to store it within the rule. But when I try to embed the script below, I get
expected "end" but found "on".
at the start of this code. Is this just a bug in Hazel, or something it just doesn't support, or do I need to do something to the code? Any suggestions are appreciated as would REALLY like to take advantage of this excellent new feature.
expected "end" but found "on".
at the start of this code. Is this just a bug in Hazel, or something it just doesn't support, or do I need to do something to the code? Any suggestions are appreciated as would REALLY like to take advantage of this excellent new feature.
- Code: Select all
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars