I'm neither a _javascript_ programmer nor a proficient Jmol scripter but
would these options be workable with those technologies:
1. Is there a way to check if Jmol is ready (either in _javascript_ or
Jmol)? Do somehting like this:
while(! isJmolReady()) {
wait for 0.1s
}
Call the Jmol script or send the callback if working from Jmol
2. Catch the error thrown and retry the script:
retry = true;
while(retry)
try {
runJmolScript();
retry = false; // if we get this far the script has succeeded.
} catch (Exception e) {
wait for 0.1s
}
}
I did this with Java-like syntax. I don't know how _javascript_ does
error handling but you could do something similar if it uses an ON
ERROR GOTO mechanism.
Hope that helps.
Cheers,
Chris.
Ian Thomas wrote:
Hi Angel,
Angel Herráez wrote:
In my experience, the only safe solution is to have Jmol call the
_javascript_, and to include that call in the jmolApplet() call itself.
So, it could be something like
jmolApplet(300, 'load myFile.cif; _javascript_ "parseAtoms()"; ')
I tried what you suggested but I still have the same intermittent
problem: sometimes the call to jmolGetPropertyAsArray("atomInfo", "all")
returns nothing, presumably because Jmol has not finished initialising
at that point. Other times, I do get a property array back, but the
inidividual objects within the array don't have an 'info' property for
some reason, so my function still fails but in a different place.
It seems that even if I call my _javascript_ function from within the Jmol
scripting layer itself, it still doesn't seem to run in a synchronised
fashion. I even tried setting my function as a callback:
set LoadStructCallback "jmol_update_disorder()";
I assumed this would guarantee that my _javascript_ wouldn't run until
after Jmol has finished loading the molcule, but sadly this too suffers
from the same intermittent problem. Is this an example of a more general
Jmol scripting problem?
Unless anyone has any other suggestions, it appears I will have to
abandon my new functionality completely as I'm out of ideas and I cannot
get it to work reliably. :-(
Thanks for your help,
Ian
LEGAL NOTICE
Unless expressly stated otherwise, information contained in this
message is confidential. If this message is not intended for you,
please inform [email protected] and delete the message.
The Cambridge Crystallographic Data Centre is a company Limited
by Guarantee and a Registered Charity.
Registered in England No. 2155347 Registered Charity No. 800579
Registered office 12 Union Road, Cambridge CB2 1EZ.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users
|
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users