Bob, Before I get to my questions, I’ll note that I discovered that I could get the number of models directly from the java object approach - forget the previous emails on this subject. Now to the point of this email...
I think I’m catching on, but I don’t fully get it. I see the ease of grabbing a single property, and I converted some of my code to do that. But consider the old and new way below. In both snippets, I’m getting the molecular formulas of a number of models in the window and calculating the mono-isotopic mass of each. The regex expressions are just getting the formulas into arithmetic format with symbols defined as numeric variables in the over all function. It’s just this snippet that concerns me in this email: OLD WAY var strMods =Jmol.evaluateVar(jmolApplet0, "getProperty('moleculeInfo.mf')").toString().split(",”); for (var i = 0; i < strMods.length; i++) { strMods[i] = strMods[i].replace(/([a-z])\s([0-9])/ig, '$1\*$2').replace(/([0-9])\s([a-z])/ig, '$1\+$2'); echoStr += "" + roundnum(eval(strMods[i]), 4) + " | "; } NEW WAY var strMods = Jmol.getPropertyAsJavaObject(jmolApplet0,"moleculeInfo.mf"); var mf; for (var i = 0; i < strMods.size(); i++) { mf = strMods.get(i).replace(/([a-z])\s([0-9])/ig, '$1\*$2').replace(/([0-9])\s([a-z])/ig, '$1\+$2'); echoStr += "" + roundnum(eval(mf), 4) + " | "; } Both work, but two questions: 1) Am I on the right track with the NEW WAY? It works, but could the code be cleaner? 2) One advantage of the NEW WAY is that this is a monstrosity in the OLD WAY: var strMods =Jmol.evaluateVar(jmolApplet0, "getProperty('moleculeInfo.mf')").toString().split(",”); The NEW WAY I have an object ready to go. Are there other advantages? Otis -- Otis Rothenberger o...@chemagic.org http://chemagic.org ------------------------------------------------------------------------------ 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=278785471&iu=/4140 _______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users