1 Reply Latest reply on Oct 10, 2013 5:13 AM by 4everJang

    How to clone a data structure object (ExtendScript)?

    Russ Ward Level 4



      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?




        • 1. Re: How to clone a data structure object (ExtendScript)?
          4everJang Level 3

          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.