I believe so, yes. Any assignment of a variable to an array produces two
references to that array, not a copy.
To copy an array, you need to use
tcolor = [ ]
tcolor += tcolorold
On Tue, Feb 7, 2012 at 10:04 AM, Yves Noel <yves.n...@upmc.fr> wrote:
> Hello Jmol-users!
>
> I have a question
>
> In a script, I have declared 2 arrays tcolor and tcolorold
> tcolor=array();
> tcolorold=array();
>
> Then I put the string "white" in every elements of the array tcolor (n
> is previously defined)
> for(i=1;i<=n;i++){tcolor=tcolor+"white";}
>
> For the moment tcolorold should contain the same as tcolor; so I wrote
> tcolorold=tcolor;
> A print command of both arrays confirms that they contain the same thing.
>
> Then I want to modify only the tcolor content (let's say element number 4)
> tcolor[4]="red";
>
> If I check now the content of tcolorold, IT HAS CHANGED!!
> print tcolorold[4];
> => red
> tcolorold seems to have a permanent link with tcolor (since the
> tcolorold=tcolor; command)
>
> Is this a normal behaviour?
>
>
> I have performed another test:
> tcolor=array();
> tcolorold=array();
> for(i=1;i<=n;i++){tcolor=tcolor+"white";}
> for(i=1;i<=n;i++){tcolorold[i]=tcolor[i];}
> tcolor[4]="red";
> print tcolorold[4]
> => white
>
> No link between tcolor and tcolorold
>
> Is this a normal behaviour?
>
> Thank you for your help.
>
>
> Yves
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107
If nature does not answer first what we want,
it is better to take what answer we get.
-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users