Yes, Ron, I did miss your post.
I've since played around a little, and was able to repro the problem, but only when using
hard-quantized MIDI where "melody" and "chord" note start times were identical. I also noticed that notes that were not selected initially become selected after processing. So, though I haven't looked at the CAL, myself, it appears that the CAL may be adding to the selection as it processes, and it has problems with notes that have identical start times.
This latter issue isn't too surprising because obviously there's a logical problem about what to do when the "next" note starts at the same time as the "current" one. Obviously legato makes more sense for a monophonic voice/line where it's impossible for two notes to start at the same time. Selecting only melody notes should avoid that problem, but if CAL is adding to the selection as it processes so that it can encounter other notes that start at the same time that's going to be a problem.
Some things I saw also seemed to suggest that the CAL might not be re-initializing variables properly when it's run a second time, or maybe pointers aren't getting disposed of by SONAR. Undoing, re-selecting and running it again can give different results the second time.
Since CAL is deprecated, and CAL scripts tend not to be very thoroughly debugged, especially with regard to unexpected input, anything is possible.
All that said, I haven't seen a problem when selecting a melody line and a running legato.cal in an
unquantized piece that didn't have any selected notes starting on the exact same tick as some other note.