AppleScript error

I have a Hazel rule that analyses PDF files and generates tokens found in Contents --> Contain Match to find number strings (eg: "333.00" or "59.95").
The rule which passes tokens corresponding to those numbers into an AppleScript and I want to get it to pass back a calculated result to use as a token, but it's not working.
I know the Hazel rule is passing parameters correctly (tested with another script) but I can't get the above script to pass back the result to Hazel. Must be something to do with the last line of code to return the result? I've confirmed the script gets at least that far by adding a "beep" command just before it (I couldn't figure out another way to debug and see how far it gets - would love tips on smarter ways to do this!)
The rule which passes tokens corresponding to those numbers into an AppleScript and I want to get it to pass back a calculated result to use as a token, but it's not working.
- Code: Select all
on hazelProcessFile(theFile, inputAttributes)
#Set variables based in input attributes from Hazel
set theAmount to item 1 of inputAttributes as text
set theWaterCharges to item 2 of inputAttributes as text
set CouncilCharges to (convNum(theAmount) - convNum(theWaterCharges)) as number
return {hazelStop:false, hazelSwitchFile:myFile, hazelOutputAttributes:CouncilCharges}
end hazelProcessFile
on convNum(x as text)
return x as number
end convNum
on convStr(y as number)
return y as text
end convStr
I know the Hazel rule is passing parameters correctly (tested with another script) but I can't get the above script to pass back the result to Hazel. Must be something to do with the last line of code to return the result? I've confirmed the script gets at least that far by adding a "beep" command just before it (I couldn't figure out another way to debug and see how far it gets - would love tips on smarter ways to do this!)