Hi @makudu, try adding a semicolon at the end of these statements.
The first statement wasn't terminated (there's a comma at the end of the line), so the next token when parsing the script, long is unexpected.
double msglen = doc['message.keyword'].value.length();
long msgcast = msglen;
return msgcast;