I finally realized that I never specified what the VAR keyword does exactly.
So if you are interested, please check out the documentation now.
http://chemapps.stolaf.edu/jmol/docs/?ver=12.0#jmolmathglobalandlocalscope
Since it wasn't documented anyway, I took the liberty of fixing a
bug/feature in Jmol 12.0.RC4. Note that this fix could break a few scripts -
primarily my own! -- depending upon how much you have done with VAR.
Formerly if you did this:
i = "test"
for (var i = 0; i < 10; i++) {
....
}
print i
You would get "10". The "var" localization only applied to the script or
function containing this loop, not the loop itself. That's consistent with
JavaScript, but not Java. I decided to go with Java and now "var" in that
context defines the variable only for that loop. So in Jmol 12.0, that would
print "test" instead of 10.
Same with while() loops:
while (i < 10) {
var x = 3
....
i++
}
In Jmol 11.8, x would now be 3. In Jmol 12.0, x is not defined outside that
loop. (It would be an empty string, "".)
In addition, you can now "isolate" a variable using:
{
var x = ...
}
and it will not be defined outside the { .... } construct. You couldn't do
that at all in Jmol 11.8. The first brace would just throw an error.
Ultimately what I was after was a way to define variables associated with a
specific command so that they could be automatically dispensed with when no
longer needed:
{
var x1 = load("myfile")
isosurface inline @x1
}
That sort of thing. So we may see some changes in the way the Jmol state is
defined. We'll see. Now I'm not so sure it will work for me in that context.
We'll see.
Oddly enough, now you can do this:
for (var i = 0; i < 10; i++) {
for (var i = 0; i < 10; i++) {
print "inner i = " + i
}
print "outer i = " + i
}
Of course, if you do that, you lose access to the outer i within the inner
loop.... Please don't do this!
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
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users