Oh you can remove all those echos
I put them in there for debugging to see where it was stopping somewhere I wasn't seeing, but forgot to remove them.
Logic errors:
Anyways, getWord and getWords start counting at 0, while getWordCount starts at 1. So change the last part of the if check for your subtraction, 'getWordCount(%msg) == 4' to 'getWordCount(%msg) == 5' and change '%b = getWord(%msg,5);' to '%b = getWord(%msg,4);'
You're also subtracting the wrong way: change '%c = %a - %b;' to '%c = %b - %a';
I don't see the syntax error though