Skip to main content
Legend
September 24, 2013
Question

How to clone a data structure object (ExtendScript)?

  • September 24, 2013
  • 1 reply
  • 807 views

Hi,

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?

Thanks,

Russ

This topic has been closed for replies.

1 reply

4everJang
Legend
October 10, 2013

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.

Ciao

Jang