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

Reply via email to