Skip navigation
Currently Being Moderated

How to clone a data structure object (ExtendScript)?

Sep 24, 2013 8:16 AM



Is there some quick way to clone a data structure, like a text range, rather than doing all this:


newTR = new TextRange();

newTR.beg.obj = oldTR.beg.obj;

newTR.beg.offset = oldTR.beg.offset;

newTR.end.obj = oldTR.end.obj;

newTR.end.offset = oldTR.end.offset;


I tried this, but it failed as I expected:


newTR = oldTR.clone();


I tried this, but I got back the same object:


newTR = new TextRange(oldTR.beg, oldTR.end);


Any ideas?




  • Currently Being Moderated
    Oct 10, 2013 5:13 AM   in reply to Russ Ward

    Hi Russ,


    A little late in responding, and not much to help you forward, I'm afraid. The TextRange object seems to merely contain pointers to its objects, rather than copies of the objects themselves. I have run into problems even setting the offset of the beg and end objects separately without first creating two new objects for them explicitly. Strange animals, those TextRanges.





    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points