Jmol developers,
OK, I've checked in a revision of 11.3.23 that fixes some bugs relating
to local variables and also adds break and continue to for and while.
Since we have "goto" as well, one doesn't really need "break [label]" or
"continue [label]", so for now I will leave those out.
There could very well be a few more bugs to find. But I tested it on the
script below, and it seemed to behave properly. The "var" keyword was
causing me some problems, but I think that's OK now. We'll see.
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.
Looks like a whole new chapter or two in that book we were talking about.
Bob
---------------
load data/caffeine.xyz;color background white;
function d(i,j)
return {atomno=i}.distance({atomno=j})
end function
var n = {*}.size
var isOK = true;
for (var i = 1; i <= n && isOK; 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
measure {atomno=i} {atomno=j}
isOK = false;
break;
end if
print "long";
end for
end for
var i = 4
if (i = 3)
print "i=3"
elseif (i=4)
print "i = 4"
elseif (i = 5)
print "i=5"
endif
while ( i > 0)
i = i - 1
if (i = 3);continue;endif
print "atom " + i + " " + {atomno=i}.ident + " is at " + {atomno=i}.xyz
if (i = 2);break;endif
end while
n = {*}.size
for (i = 1; i <= n; i = i + 1)
for (j = i + 1;j <= n; j = j + 1)
var dist = {atomno=i}.distance({atomno=j})
if (dist < 1.77)
print "i-j: " + i + "," + j + " " + dist%2
var line = "line"+i+"_"+j
draw @line {atomno=i} {atomno=j}
endif
end for
end for
x = 6
if (x = 3)
print "no"
else if (x = 4)
print "x is 4"
else if (x = 5)
print "x is 5"
else
for (var i = 0; i < 4; i = i + 1)
print "in for: i="+i
if (i = 2);print "i is 2";endif
end for
print "three"
end if
--
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-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers