[EMAIL PROTECTED] wrote:

>Bob, 
>
>Thanks for the reply.
>
>  
>
>>scriptWait() should do precisely what you are interested in doing. I 
>>think you just haven't found the right way to wait on that thread.
>>    
>>
>
>All I've tried is simply 'viewer.scriptWait(command)' in a block
>of otherwise functioning, thread-naive, java code. This causes the app
>to hang
>indefinitely on this line. 
>
>  
>
this surprises me. I'll try that myself. Clearly it can work -- Jmol is 
doing it already. What could it be? Miguel should know.

>'viewer.script(command)' in the same
>place works OK, provided this is the only command I need
>to issue, as described.
>
>Do I need to do something special to the viewer.scriptWait() in order to 
>wait on it?
>  
>
I don't think so. The code is simply this:

    Eval e = new Eval(this);
    if (e.loadScriptString(strScript, false)) {
      e.runEval();
    }

You could make a "budget" scriptWait that doesn't return any strings and 
see if that works better for you:

void scriptWaitVoid(String strScript) {
    Eval e = new Eval(this);
    if (e.loadScriptString(strScript, false)) {
      e.runEval();
    }
}

Do you want to try that?

I do note that the Jmol.java piece of this is synchronized to prevent 
multiple simultaneous scripting.

  synchronized public String scriptWait(String script) {
    return viewer.scriptWait(script);
  }  
 
could there be a problem with that?

Bob


>I am pretty much ignorant about threads in any language, particularly
>java.
>
>Thanks,
>
>Dave
>
>
>  
>
>>BUT there are a few eval commands that start animation threads, and 
>>these threads may not wait. For them you have to add something like
>>
>> delay 5  #wait 5 seconds
>>
>>to allow for the animation to complete
>>
>>I just did this:
>>
>>jmolScriptWait("load 1crn.pdb;isosurface solvent")
>>
>>which takes several seconds to render the solvent-excluded surface for 
>>1crn, and it waited.  (That was from an applet, but there's no 
>>difference for an application, I think.)
>>
>>
>>Bob
>>
>>[EMAIL PROTECTED] wrote:
>>
>>    
>>
>>>(This refers to Bob Hanson's Jmol 10.x branch)
>>>
>>>Hi,
>>>
>>>I'm writing an application which is basically an extended version
>>>of the Jmol app, and I need to issue scripting commands
>>>via viewer.script() or similar methods.
>>>
>>>I would like to be able to give a number of these commands in
>>>sequence, but simply doing 
>>>viewer.script(command1);
>>>viewer.script(command2);
>>>
>>>doesn't work. I expect this is because the scripting commands
>>>happen in a thread in Eval, but I don't know enough about threads
>>>to know what to do about this.
>>>
>>>Sometimes I can get away with 
>>>viewer.script(command1 + ";" + command2);
>>>
>>>but sometimes the logic required to construct command2 depends
>>>on what I did in command1 (e.g. loading a molecule).
>>>
>>>What I want is a method which executes a script, then
>>>waits for the script to finish, then continues. 
>>>I've tried scriptWait(), and a while (isScriptExecuting()) loop
>>>with no success.
>>>
>>>Any ideas or explanations of what I'm doing wrong gratefully received,
>>>
>>>Thanks
>>>
>>>Dave
>>> 
>>>
>>>      
>>>
>>
>>-------------------------------------------------------------------------
>>Using Tomcat but need to do more? Need to support web services, security?
>>Get stuff done quickly with pre-integrated technology to make your job
>>easier
>>Download IBM WebSphere Application Server v.1.0.1 based on Apache
>>Geronimo
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>_______________________________________________
>>Jmol-developers mailing list
>>[email protected]
>>https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>    
>>



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to