Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

jmol-users

 [Jmol-users] Jmol 11.3.23 and scripting From: Bob Hanson - 2007-09-16 18:56:13 ```Jmol just took a quantum leap in the area of scripting. The following is a valid Jmol script, as of Jmol 11.3.23, which Nico just released: load data/caffeine.xyz;color background white; function d(i,j) return {atomno=i}.distance({atomno=j}) end function var n = {*}.size for (var i = 1; i < n; i = i + 1) for (var j = i + 1;j <= n; j = j + 1) var dis = d(i,j); if (dis < 1.23) print "short i-j: " + i + "," + j + " " + dis%2 measure {atomno=i} {atomno=j} continue; else if (dis < 1.77) print "medium i-j: " + i + "," + j + " " + dis%2 var line = "line" + i + "_" + j draw @line {atomno=i} {atomno=j} break 1; end if end for end for No, it's not JavaScript. It's not Java. It's Jmol. Take a look and you will see measure and draw commands in there. I realize that it's hard to believe this is a Jmol script. But it is. You get a sense of the ramifications of this when you take a look at that d(i,j) function and the measure command being used or a bit further down with: var line = "line"+i+"_"+j draw @line {atomno=i} {atomno=j} Notice the {atomno=i} mixing of selection of atoms based on atomic properties and math variables. I think this is really where the interesting part is going to be. Now we have macros, subroutines, functions, local variables, and several new capabilities beyond the basic "if/else/endif" or "goto": if else if else end if while end while for end for goto _label message _label function end function A bit more discussion may be found at http://chemapps.stolaf.edu/jmol/docs/?ver=1.4 There could very well be a few more bugs to find, so if you go for this sort of thing, do look out for it misbehaving. Looks like a whole new chapter or two in that book we were talking about. Bob -- Robert M. Hanson Professor 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 ```
 Re: [Jmol-users] Jmol 11.3.23 and scripting From: pim schravendijk - 2007-09-18 15:57:36 ```Excellent looping (I didn't like the looping before much), and pretty straightforward to understand, but why the goto? For all fortran addicts? :) I didn't install the new release yet, will jmol still interpret javascript in load files? Can the languages be mixed? On 9/16/07, Bob Hanson wrote: > Jmol just took a quantum leap in the area of scripting. > -- Greetings, Pim http://www.molmod.com ```
 Re: [Jmol-users] Jmol 11.3.23 and scripting From: Bob Hanson - 2007-09-18 16:13:12 ```pim schravendijk wrote: >Excellent looping (I didn't like the looping before much), and pretty >straightforward to understand, but why the goto? For all fortran >addicts? :) > > > Fortran, are you kidding? DOS-BASIC!! :) Seriously, we had the goto; it does no harm; eh..... >I didn't install the new release yet, will jmol still interpret >javascript in load files? Can the languages be mixed? > > > you mean Jmol script, right? Yes and yes. It's one language. >On 9/16/07, Bob Hanson wrote: > > >>Jmol just took a quantum leap in the area of scripting. >> >> >> > > > > -- Robert M. Hanson Professor 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 ```