Dear Bob,

Thanks for the good overview and examples which I found very very useful!

Here is what I am trying to do. Please suggest the best way to handle this.

(I remind you that way back in 2005 I made the decision not to use Jmol.js. At 
this point it seems easiest not to rewrite FirstGlance to use Jmol.js. The lack 
of Jmol.js has not caused any problem that I am aware of.)

I am trying to detect the case when a PDB file is requested (by FirstGlance in 
Jmol) but is not available. The most likely case is when the PDB file 
corresponding to a new article in Nature has not been released on the date of 
publication, which occurs because nobody tells the PDB in advance when 
publication will occur. The PDB file is in the PDB but has status "HPUB" (hold 
for publication), so is not publically available. 

A current example (should remain HPUB at least until next Tuesday's new release 
batch) is http://www.rcsb.org/pdb/cgi/export.cgi/3IYE.pdb.gz

So Jmol applet gets the command
load http://www.rcsb.org/pdb/cgi/export.cgi/3IYE.pdb.gz

this URL is redirected to
http://www.rcsb.org/pdb/nosuchfile.jsp

Jmol 11.8.14 generates this in the messageCallback stream:
script 
ERROR: java.io.FileNotFoundException: http://www.rcsb.org/pdb/cgi/export.cgi/3IYE.pdb.gz

Jmol displays this in a tiny red font at the top:
java.io.FileNotFoundException: http://www.rcsb.org/pdb/nosuchfile.jsp

My code watches the messageCallback stream for "FileNotFoundException" in the 
same line as "error" (ignoring case) and if this occurs, attempts to say 
something helpful to the user. My current code is confounded by the multiple 
concurrent messageCallbacks. 

(FirstGlance is installed together with an Apache server rewrite rule so the 
unsigned applet can fetch PDB files from other servers.)

Thanks, -Eric

--- On Sat, 1/23/10, Robert Hanson
 <hans...@stolaf.edu> wrote:

From: Robert Hanson <hans...@stolaf.edu>
Subject: Re: [Jmol-users] messageCallback again, before return
To: jmol-users@lists.sourceforge.net
Date: Saturday, January 23, 2010, 4:57 PM

Eric, right,this is the problem with callbacks. Can you give us some examples 
of why you are using callbacks? If it is to gather information that you really 
want NOW not later, then a callback is the wrong mechanism. There are three
 replacement mechanisms we have gone to, leaving callbacks for user action 
responses. They are very direct, immediate, and useful. 


I hope one of these will work for you. 

1) jmolEvaluate()

This extremely useful method returns a value directly. Anything that can be put 
on a "print" command can be put here.

var myJsVar = jmolEvaluate("script('show fileHeader')")


alert(jmolEvaluate("{*}.label('%a\\t%n %5.3x\\t%5.3y\\t%5.3z')"))


2) jmolScriptWaitOutput()

This function returns exactly what would go to the console synchronously. 

alert(jmolScriptWaitOutput("show pdbheader"))


3) jmolGetPropertyAsXXXXX()

Three functions: 

jmolGetPropertyAsString(....)
jmolGetPropertyAsArray(...)
jmolGetPropertyAsJSON(...)

allow you to use the "getProperty" command and directly access structured data. 


alert(jmolGetPropertyAsArray("modelInfo").modelCount)

javascript:alert(jmolGetPropertyAsString("fileInfo","remark2"))

This "fileInfo" one is all the information in the CIF or PDB file header. 


alert(jmolGetPropertyAsString("fileinfo.models[1]._cell_length_c")


Bob


On Sat, Jan 23, 2010 at 2:02 PM, Eric Martz <martze...@yahoo.com> wrote:



In FirstGlance in Jmol I am using messageCallback more and more. Today I found 
why some control javascript that I wrote over a year ago, that relies on 
messageCallback, has been behaving strangely and basically not working. I have 
been working with Jmol 11.8.14 applet but upgrading is no problem.

It seems that the next messageCallback occurs before the 
previous messageCallback has returned. My callback function is currently 
returning nothing. Thus, 6 (or possibly more) callbacks can be executing 
concurrently and asyncronously with each other. Because I did not anticipate 
this, the values of my external variables set in the callback function are set 
in an unpredictable way with
 unpredictable results.
What I observed is that if I put alerts in the callback function, and if those 
alerts report the number of the callback (1 for the first callback, 2 for the 
second, and so forth) I see 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1. In other words, 
callback 6 often (but not always?) completes and returns before callback 1 
completes and returns. My interpretation of this is in the previous paragraph.

Is there some way I can force messageCallback to wait for return of the
 function it calls before the next messageCallback occurs? If not, I can 
redesign some code and hopefully get it to work, but it seems to me that in 
general the "wait for return" would be a good thing.

Thanks, -Eric





      

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to