Nice, Otis! Yes, evaluateVar is the way to go.

One way to make that a bit more understandable:

function compareSmiles(key, ans) {
    var v = " 'KEY'.find('SMILES','ANS')>0"
        .replace(/ANS/,ans)
        .replace(/KEY/,key)
        .replace(/\\/g,"\\\\")
    return Jmol.evaluateVar(jmolApplet0, v);
}

On Sun, Jan 10, 2016 at 11:51 AM, Otis Rothenberger <osrot...@icloud.com>
wrote:

> Hi Ashok,
>
> As Angle and Bob mentioned in their notes, you need to do this in
> JavaScript. Here’s a simple function that gets the job done:
>
> function compSmiles(key, ans) {
> key = key.replace(/\\/g, '\\\\');
> ans = ans.replace(/\\/g, '\\\\');
> return Jmol.evaluateVar(jmolApplet0, "'" + key + "'.find('SMILES','" + ans
> + "') > 0");
> }
>
> It returns true or false. The crazy replace code is needed to deal with
> the SMILES \ inside a JavaScript variable!
>
> Otis
>
> --
> Otis Rothenberger
> o...@chemagic.org
> http://chemagic.org
>
> On Jan 10, 2016, at 11:33 AM, T. Ashok Kumar <
> ashok.bioinformat...@gmail.com> wrote:
>
> I designed a trial webpage to display the console window alone and run the
> script. It works fine. But, I am trying to run the script without the
> console window, and display the output inside the webpage ( like *var y =
> result;* and *document.write(y); *)
>
> *HTML Source Code:*
>
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="utf-8">
> <title>JSmol Console</title>
> <script type="text/javascript" src="JSmol/JSmol.min.js"></script>
> <script type="text/javascript">
> var x = {
> debug: false,
> color: "white",
> addSelectionOptions: false,
> use: "HTML5",
> j2sPath: "JSmol/j2s",
> jarPath: "JSmol/java",
> jarFile: "JmolAppletSigned.jar",
> isSigned: true,
> serverURL: "JSmol/php/jsmol.php",
> readyFunction: null,
> disableJ2SLoadMonitor: true,
> disableInitialConsole: true,
> allowJavaScript: true
> }
>
> $(document).ready(function() {
>   $("#app").html(Jmol.getAppletHtml("jmolApplet0", x));
>   Jmol.script(jmolApplet0, 'set antialiasDisplay; load
> JSmol/data/caffeine.mol');
>   Jmol.script(jmolApplet0, 'console');
> })
> </script>
> </head>
> <body>
> <div id="app" style="display: none;"></div>
> </body>
> </html>
>
> *Script:*
>
> smiles1 = "C(=C(C(=N1)C)O)(C(=C1)CO)CO";
> smiles2 = "CC1=NC=C(C(=C1O)CO)CO";
> result = smiles2.find("SMILES", smiles1);
> if(result > 0)
> {
> print "Both SMILES are same.\nScore:" + result;
> }
> else
> {
> print "Both SMILES are different.";
> }
>
>
> --
> *T. Ashok Kumar*
> Head, Department of Bioinformatics
> Noorul Islam College of Arts and Science
> Kumaracoil, Thuckalay - 629 180
> Kanyakumari District, INDIA
> Mobile:- 00 91 9655307178
> *E-Mail:* *ashok.bioinformat...@gmail.com
> <ashok.bioinformat...@gmail.com>*,
>              *as...@biogem.org <as...@biogem.org>*
> *Website:* *www.biogem.org <http://www.biogem.org/>*
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
>
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> 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


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
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to