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



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to