exactMass()

User a719ee09dd

05-04-2011 15:03:21

Hello,


I wish I had the exact molar mass with more than two digits after the decimal point.

I used the "exactmass()" in Javascript in a html page with the applet MARVIN SKETCH.


<script type="text/javascript"> 
function envoyer(theForm) {
if (document.MSketch.isEmpty()) {
alert("erreur");
}
else {
theForm.mol.value=document.MSketch.getMol('mol');
theForm.massmol.value=document.MSketch.evaluateChemicalTerms('exactmass()');
theForm.formbrut.value=document.MSketch.evaluateChemicalTerms('formula');
theForm.submit();
}
}
</script>



I get the molar mass with only two digits after the decimal point.

How to have more digits after the decimal point in decimal?


Thank you for your reply.

ChemAxon e08c317633

11-04-2011 15:56:57










kingos wrote:


I get the molar mass with only two digits after the decimal point.

How to have more digits after the decimal point in decimal?



Unfortunately in javascript it is not yet possible to set the number of decimal digits.
We have registred this feature request.


Zsolt

User 613c6cda4d

13-04-2011 15:10:10

Hi


To have more digits after the decimal point you should emphasize the command:


getMolFormula()




For your code that gives this transformation :


 




<script type="text/javascript"> 
function envoyer(theForm) {
if (document.MSketch.isEmpty()) {
alert("erreur");
}
else {
theForm.mol.value=document.MSketch.getMol('mol');
theForm.massmol.value=document.MSketch.evaluateChemicalTerms('exactmass()');
theForm.formbrut.value=document.MSketch.getMolFormula();
theForm.submit();
}
}
</script>


Best regards.

ChemAxon e08c317633

14-04-2011 15:25:30

Robin, thanks for the comment.


Meanwhile I realized we already have a getMolExactMass() function in JMSketch, which returns the exact mass without rounding. So please call


document.MSketch.getMolExactMass()

See:
http://www.chemaxon.com/marvin/help/developer/applets/api/chemaxon/marvin/applet/JMSketch.html#getMolExactMass()
http://www.chemaxon.com/marvin/help/developer/applets/api/chemaxon/marvin/applet/JMSketch.html


In the future we will solve setting the number of decimal digits in evaluateChemicalTerms() function too.


Zsolt