Jeff, why don't you come over to St. Olaf and I'll show you how this works!
:)
Seriously, hang in there. You are trying to do a lot all at once, and you
will catch on. This is precisely what this list is for. Just keep at it.
"jmolScriptWait" would not "break" anything.
jmolScriptWait should only be used if you absolutely have to pause the
JavaScript until that operation is complete. There are times this is
necessary, but it's not a great idea.
Most Jmol commands are given "asynchronously" using jmolScript() rather than
jmolScriptWait(). Jmol has a built-in queuing system, so you can fire as
many commands at it as you wish, and they will be processed in order as
processing becomes available. You can also clear the queue using
!exit
and you can abort a specifically running script (but continue processing
later scripts) using
!quit
An alternative to waiting is to have the issued script notify the web page
when it is complete. Eric Martz and Tim Driscoll masterminded this idea
using "scriptcallback" methods that see a comment go by and then know it is
time to do something. Something like this:
set scriptcallback "myfunc";set debugscript true;load whatever;#--file is
loaded
then myfunc() gets a message every time a script command is executed, and
the "#--file is loaded" message comes through as well:
function myfunc(app, msg) {
var s = "" + msg // converts Java string msg into a JavaScript string
if (s.indexOf("#--file is loaded") == 0) {
[do something]
}
}
Alternatively, I've used the following quite effectively:
jmolScript("load whatever;javascript modelLoaded()")
That would run the JavaScript function
function modelLoaded() {
}
as soon as the model is loaded.
Basically, good "event driven" code is asynchronous. Nothing waits for
anything. Things happen because they get a message that they need to happen.
The more you can do that, the better.
Still, I do use jmolScriptWait() myself at times. Also jmolEvaluate() is
synchronous, and I use that a lot as well.
Bob
On Thu, Aug 28, 2008 at 6:30 PM, Jeff Hansen <[EMAIL PROTECTED]> wrote:
> I tried jmolScriptWait but couldn't get it to not break the load
> command.
>
>
> ***********************************************
> Jeff Hansen
> Department of Chemistry and Biochemistry
> DePauw University
> 602 S. College Ave.
> Greencastle, IN 46135
> [EMAIL PROTECTED]
> ***********************************************
>
>
> On Aug 28, 2008, at 6:03 PM, Jeff Hansen wrote:
>
> > Sorry I wasn't clear about this, but the applet corresponding to
> > result1 is loaded when the page loads. I'll try jmolScriptWait to see
> > if that does anything for the result2.
> >
> > fffff
> > ***********************************************
> > Jeff Hansen
> > Department of Chemistry and Biochemistry
> > DePauw University
> > 602 S. College Ave.
> > Greencastle, IN 46135
> > [EMAIL PROTECTED]
> > ***********************************************
> >
> >
> > On Aug 28, 2008, at 5:41 PM, Angel Herráez wrote:
> >
> >> On 28 Aug 2008 at 15:59, Jeff Hansen wrote:
> >>
> >>> Additionally, the alert(result1) (see code below) displays undefined
> >>> in the alert box and alert(result2) displays a blank alert box. So
> >>> I'm wondering what is going on with that.
> >>
> >> I would say that with result1 you are trying to read from the applet
> >> before it has been
> >> created, so it's not surprising thayt you get undefined.
> >> As for result2, I'm not sure because I don't know the try/catch
> >> command, but anyway it may
> >> be too soon to have the applet ready. Javascript goes much faster
> >> than loading Java +
> >> Jmol.
> >>
> >>
> >>
> >>
> -------------------------------------------------------------------------
> >> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> challenge
> >> Build the coolest Linux based applications with Moblin SDK & win
> >> great prizes
> >> Grand prize is a trip for two to an Open Source event anywhere in
> >> the world
> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> _______________________________________________
> >> Jmol-users mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/jmol-users
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win
> > great prizes
> > Grand prize is a trip for two to an Open Source event anywhere in
> > the world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Jmol-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
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
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users