I have several script that iterate through every event on a track. They usually work just fine. However, I have a project with 3,500 events, half of these on one track, and even my 3.2 GHz i7 computer takes over thirty seconds to get through all of them. I therefore conclude that I must be using a very inefficient script construct. The simplest script function is shown below. All it does is to select the event under the current cursor location on the first selected track, and then deselect all other events on that track.
Is there a more efficient way to do this using jscript? If I created a cs version of the script, would it be faster? I obviously could try to compile it, but I don't do that kind of programming any more and the one computer that has a compiler installation hasn't bee used for a decade.
Thanks for any help or hints you can provide.
Is there a more efficient way to do this using jscript? If I created a cs version of the script, would it be faster? I obviously could try to compile it, but I don't do that kind of programming any more and the one computer that has a compiler installation hasn't bee used for a decade.
Thanks for any help or hints you can provide.
function SelectEventAtCursor() {
var EventFound : boolean = false; // Function returns false if no video media under cursor.
dCursor = Vegas.Cursor.ToMilliseconds(); // Remember the cursor position.
//Go through each event on the track.
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event
// Get the event's start and length timecode, in milliseconds.
dStart = evnt.Start.ToMilliseconds();
dLength = evnt.Length.ToMilliseconds();
/**
* If the cursor timecode is between the beginning and end of the
* event timecodes, then select the event.
**/
if ( (dCursor >= dStart) && ( dCursor < (dLength + dStart) ) ) {
evnt.Selected = true; // Select this event.
EventFound = true;
CurrentEvnt = evnt;
}
eventEnum.moveNext(); // Go to next event on this timeline.
}
return EventFound;
}