Thanks Robert for the nice overview. Its definitely good to know the details of them each..

Martin






Am 09.11.11 13:53, schrieb Robert Hanson:
OK, there are really several JavaScript functions of value here:

jmolScript
jmolScriptWait
jmolScriptWaitOutput
jmolEvaluate
jmolGetPropertyAsArray
jmolGetPropertyAsJSON
jmolGetPropertyAsString
jmolGetPropertyAsJavaObject

*jmolScript
*
 -- very generally useful.
-- submits a command to a queue and returns immediately, before the command is checked or executed. -- "!" at the beginning forces immediate execution even if another command is executing -- "quit" alone stops the currently running script and goes to the next script in the queue
 -- "exit" stops all script processing -- even queued up scripts
-- "quit" or "exit" as the first of a set of commands in a script stops processing,
          clears the queue and runs this script only

*jmolScriptWait
*
-- waits for currently executing commands to finish, executes a command, and returns a rather cryptic array of messages associated with that. This list is ordered by callback type but can be reordered by time based on the first number in each array (each line, here)

alert(jmolScriptWait("print {*}.element.all"))

  2,"scriptStatus",0,"script 3 started\n"
  4,"scriptStatus",0,"Script completed\n"
  6,"scriptStatus",0,"Jmol script terminated\n"
  5,"scriptTerminated",1,"Jmol script terminated successfully\n"
  1,"scriptStarted",3,"print {*}.element.all\n"
3,"scriptEcho",0,"N | C | C | O | N | C | C | N | C | N | C | C | C | O | H | H | H | H | H | H | H | H | H | H | \n"

*jmolScriptWaitOutput
*
-- waits for currently executing commands to finish, executes a command, and returns a string
     of output (status and echo reports) from the applet
 -- can lock up the browser if used in conjunction with callbacks

alert(jmolScriptWaitOutput("print {*}.element.all"))

"script 4 started\nN\nC\nC\nO\nN\nC\nC\nN\nC\nN\nC\nC\nC\nO\nH\nH\nH\nH\nH\nH\nH\nH\nH\nH\n\nScript completed\nJmol script terminated\n"

*jmolEvaluate*

-- executes immediately and returns exactly what a Jmol "print" command would return:

 var x = jmolEvaluate("{*}.element.all")

  JavaScript variable x equals

"N\nC\nC\nO\nN\nC\nC\nN\nC\nN\nC\nC\nC\nO\nH\nH\nH\nH\nH\nH\nH\nH\nH\nH\n"

*jmolGetPropertyAsArray
jmolGetPropertyAsJSON
jmolGetPropertyAsString
jmolGetPropertyAsJavaObject
*
-- these all return the output of the "getProperty()" function in various forms.

  jmolGetPropertyAsString("auxiliaryinfo.models[1].fileName")

"file:/C:/jmol-dev/workspace/Jmol-documentation/script_documentation/examples-12/data/caffeine.mol"

  jmolGetPropertyAsArray("auxiliaryinfo.models[1]")

   {modelNumberDotted:"1.1",
fileHeader:"C8H10N4O2 | APtclcactv10291122543D 0 0.00000 0.00000 | | ", fileName:"file:/C:/jmol-dev/workspace/Jmol-documentation/script_documentation/examples-12/data/caffeine.mol",
    modelNumber:1,
    modelFileNumber:1000001,
    modelName:"1",
    initialAtomCount:24,
    title:"C8H10N4O2",
    initialBondCount:25,
    fileType:"Mol"}


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


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1


_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to