Bob,

I have to spend more time on the docs page. I did not even know that we had a 
way to generate a pivot table directly. Even though get property is not the 
best way to access mf, I’m still curious, so I’ll rephrase my question still in 
terms of mf:

Why is this:

 var strMods = Jmol.getPropertyAsJavaObject(jmolApplet0,"moleculeInfo.mf");

better than this:

var strMods =Jmol.evaluateVar(jmolApplet0, "getProperty('moleculeInfo.mf')”)

I’ll admit it was fun converting all my get properties to get java objects, but 
I’m not sure why I did it! It’s a little strange to be writing java expressions 
on a javascript page. I think I am, however, slowly grasping what actually 
happens during the java to javascript transition.

I only experienced one problem in these conversions. This javascript 
expression: Math.max.apply( Math, w ), requires an array for w. When I get the 
java object for “boundboxInfo.vector,” I needed to convert it to an actual 
array. I did not know how to do that other than converting it to a string and 
using the split on comma trick.

Otis

--
Otis Rothenberger
o...@chemagic.org
http://chemagic.org

> On Mar 29, 2016, at 8:36 AM, Robert Hanson <hans...@stolaf.edu> wrote:
> 
> I have no idea. What are you trying to do?
> 
> For molecular formula you can now use (Jmol Script):
> 
> mf =  {*}.element.all.pivot
> 
> print mf
> 
> {
>   "C"  :  2
>   "Fe"  :  15
>  }
> 
> And then put it together however you want to.
> 
> 
> On Sun, Mar 27, 2016 at 9:30 PM, Otis Rothenberger <osrot...@icloud.com 
> <mailto:osrot...@icloud.com>> wrote:
> 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 <mailto:o...@chemagic.org>
> http://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 
> <http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140>
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net <mailto:Jmol-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/jmol-users 
> <https://lists.sourceforge.net/lists/listinfo/jmol-users>
> 
> 
> 
> -- 
> Robert M. Hanson
> Larson-Anderson Professor of Chemistry
> Chair, Department of Chemistry
> St. Olaf College
> Northfield, MN
> http://www.stolaf.edu/people/hansonr <http://www.stolaf.edu/people/hansonr>
> 
> 
> 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
> 
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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

Reply via email to