Am 26.03.16 um 15:07 schrieb Otis Rothenberger: > Bob, > > I was reviewing some old code, and an atomindex vs atomno question came up. > If I load methane, the following results: > > print {*}[0].atomno returns 5 > print {*}[1].atomno returns 1 > print {*}[2].atomno returns 2 > print {*}[3].atomno returns 3 > print {*}[4].atomno returns 4 > print {*}[5].atomno returns 5 > > I understand the difference between atomindex and atomno, but I’m not sure of > the “meaning” of {*}[0].atomno. > Otis, array queries with index '0' provide the last array element in Jmol.
> The reason that I’m curious is that I do atom number renumbering during some > editing (multiple models in window), and I’m not sure that I’m doing it > correctly: > > for (var i = 1; i < {*}.length +1; i++){ {*}[i].atomno = i }; > > This is a case where nothing seems broken, but I’m suddenly concerned about > my method because of that {*}[0].atomno > It should be fine because you start with index '1'. But you should consider using the new faster 'for' loop syntax: ---- Old syntax ------ load =1deh; startTime = now(); for (var i = 1; i < {*}.length +1; i++){ {*}[i].atomno = i } print format(" (%.2f sec)", now(startTime) / 1000); (2.00 sec) ---- New syntax ------ load =1deh; startTime = now(); x={*}; for (var i from [1 x.size]){ x[i].atomno = i } print format(" (%.2f sec)", now(startTime) / 1000); (1.00 sec) ---------------------- Regards, Rolf ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140 _______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users