OK, I really need your help now. This just took a week out of my life, but I
think it will be worth it. Still, it was VERY complicated, and to get it
just right is nearly impossible. I keep finding odd or not so odd bugs, and
I'm at the stage where I just can't think anymore.
If you do any scripting, please test out Jmol 11.7.40 as much as you can and
get back to us. What I'm looking for:
1) Everything that worked before still works.
2) Scripting can now take the form familiar to Java and JavaScript
programmers:
-- You can use braces with for, if, while:
for (i = 1; i < 10; i = i +1) {
{atomno=i}.radius+=0.1
}
if ({*}.radius < 1.34) {
say this
} else {
say this
}
And I think we have a full complement of ++/--, +=, -=, *=, /=, \\=, &=, and
|=.
So this should work:
for (i = 1; i < 10; i++) {
do this
}
The forms are actually much free-er than that. If everything is on one line,
no braces are required. (semicolons are generally, though, in that case, but
not always). Some more examples:
for (i = 1; i <= 10; i++) {print {*}[i].radius}
for (i = 1; i <= 10; i++) print {*}[i].radius
for (i = 0; ++i <= 10;) {print {*}[i].temperature}
if (i < 10) { {*}[i].radius *= 2}
if (i < 10) {*}[i].radius *= 2
i = 0; while (++i < 10) {select {*}[i]; color red }
for (i = 1; i < 10; i++) print i
if (i < 10) print i else print j
for (var x = 1; x < {*}; x = x + 1) {
if ({*}[x].temperature < 10) ({*}[x]).radius = 1 else ({*}[x]).radius
= 0
}
print (i < 3 ? "yes" : "no")
Please try that out. There are a few examples at
http://chemapps.stolaf.edu/jmol/docs/examples-11/new.htm
Basically, what I think I managed to do was merge Jmol math with JavaScript.
It's not an exact match, but it's pretty close. I knew this was going to be
a challenge, but wow, was it difficult to get all the nuances right. I can't
believe I got it all working correctly, so please do let me know what you
find. What I added includes:
-- braces for if/for/while
-- standard (ifThis ? thenThis : elseThis ) syntax
-- ++i and i++, --i and i--
-- i+=n, i-=n, i*=n, i/=n, i\\=n, i&=n, i|=n
-- var for local variables -- (like JavaScript, not Java, where local
variables are local to a function, not an if/for/while block)
-- // comments
-- /* */ comments
-- /** **/ "super" comments
It sort of pains me that I spent all this time and didn't really add
anything new, just made it syntactically cleaner. Still, the underlying
workings of the script compiler and the way Jmol stores variables now is FAR
cleaner than it was before, so I think the hard part is done -- provided
this works! I'm hoping anything we find is minor.
I'm going to bed!
Bob
--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107
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
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers