Skip to main content
Participant
January 10, 2019
Answered

sequence.clone() not returning the sequence?

  • January 10, 2019
  • 2 replies
  • 573 views

Hello,

The following script throws the error "undefined is not an object" in version 13.0:

var theSequence = app.project.activeSequence;

var newSequence = theSequence.clone();

newSequence.clone();

The documentation says that it should "return a Sequence if successful, 0 if not."

My workaround is to guess the new sequence name then search all sequences in the project for that name.  Not really ideal, though it works for now.

var theSequence = app.project.activeSequence;

theSequence.clone();

var targetName = theSequence.name + " Copy";  //sets targetName to the expected name of the cloned Sequence 

var newSequence = findSequence(targetName);

newSequence.clone();

function findSequence(seqName)

{

    var targetSequence;

   

    var allSequences = app.project.sequences;

    var sequenceCount = allSequences.numSequences;

   

    for(var i = 0; i < sequenceCount; i++)

    {

        if(allSequences.name == seqName)

        {

        targetSequence = allSequences;

        i = sequenceCount;

        }

    }   

        return targetSequence;

}

Please let me know if I'm just using sequence.clone() (or javascript) incorrectly! 

Thanks!

This topic has been closed for replies.
Correct answer Bruce Bullis

clone() returns 0 if successful; the sequence is added to the list of sequences in the app (app.project.sequences).

docs

2 replies

Participant
January 10, 2019

Thanks @bbb_999 but even your attached doc link says is returns a sequence.  So it looks like your answer is correct, but the documents are wrong.

clone()

sequence.clone()

Description

Creates a clone of the given sequence.

Parameters

None.

Returns

Returns a Sequence if successful, 0 if not.

Bruce Bullis
Legend
January 10, 2019

GAH! You're right, I was looking in the wrong place.

Fixed.

Bruce Bullis
Bruce BullisCorrect answer
Legend
January 10, 2019

clone() returns 0 if successful; the sequence is added to the list of sequences in the app (app.project.sequences).

docs