I'll be releasing these soon. Some very significant additions to these
(required in 12.0.19 just to fix a bug)

The problem I noticed was this:

In previous versions of Jmol you had to be very careful with how you named
variables and functions. Simple names like "color" or "chain" that were
already Jmol commands or "tokens" could cause unexpected results.
Considering the fact that Jmol has over 1700 known tokens (which probably
means that I am the only one who actually knows them), that's a serious
problem.

So, the fix is to allow you to use any Jmol token name as a variable or
function name, provided you use it with the VAR keyword (thus localizing it
to the script you are working with):

var color = "red"
color cartoons @color

not a problem (any more).

Extending this to functions, we have two very interesting additions.

First, you can now name functions after Jmol commands and effectively
replace those commands with your own functions:

function measure(a,b) {
  print "I am measuring " + a + " " + b
  measure @a @b
}

measure {atomno=3} {atomno=5}

So that might be of use. Outside function "measure" the MEASURE command
calls our function; inside, it calls the standard Jmol command. In addition,
commands in official Jmol state scripts ALWAYS call the Jmol command, never
yours.

Second, here's something Eric Martz asked for long ago: You can now create
your own commands.

This change is just that you no longer need parentheses around function
calls. For example, here's a new command "loadPdbModel" that loads a PDB
from the local drive, if it exists, and if it does not, it gets it from
RCSB. Then it goes directly to a specific frame, if desired, and displays
the cartoon.

function loadPdbModel(pdbid, modelNumber) {
 var myfile = pdbid + ".pdb"
  try {
    load @myfile
  } catch {
    load @{"=" + pdbid} as @myfile
  }
  if (modelNumber) {
    frame @modelNumber
  }
 cartoons only; color cartoons structure
}

loadPdbModel "1crn" 0



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
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to