Well, I spent a few hours studying the rare and still existing materials about CAL scripts on the web.
I did some tests and I discovered the cause of
UNDUPE.CAL (and other scripts) do not work:
This is a bug in CAL language.
Basically events (notes, controls, etc.) should be read sequentially (by commands like forEachEvent), ie, the events should be read in chronological order.
However,
events are read from a TOTALLY RANDOM way.
Thus, it is IMPOSSIBLE to compare a previous note with a later note, because the script simply NOT BRING EVENTS IN CHRONOLOGICAL ORDER.
Certainly these old scripts worked in some older version of Sonar, but after that CAL was abandoned, Cakewalk still managed to spoil it.
As I said, it's a shame Cakewalk still provide CAL if it is no longer supported. Or they correct the CAL or remove it once and for all.