rob yang wrote:
>> I was thinking about this a little more. The standard solution to this
>> problem is to set up a callback. You can do this very simply just be using
>>
>> set messageCallback "somefunctionname"
>>
>> and then at the end of your script, or whenever you want to be sure you
>> are synchronized, just have in your script at that point
>>
>> echo APPLET_DONE
>>
>> When the callback comes, your callback method does the boundbox call,
>> and everything is synched.
>
> Thanks Bob. This works, with some minor issues. This is what I end up doing:
> ---
> var load_script = "zap; load somestructure; boundbox{all} on; set frank on;
> some other commands"
> jmolScript(load_script+'set messageCallback "temp_function";');
>
> function temp_function() {
> var property = getPropertyAsString("boundboxInfo");
> alert("just for debugging" + property); //this is just for debugging, and
> is not part of the final code
> }
> ---
> The above code gets the right value to the variable property, which is
> exactly what I need. But the temp_function gets called many times because
> messages are sent each time a jmol command completes. It's not big deal, but
> just out of curiosity, is there anyway to turn off the message or clear
> callbacks? For example, after the boundbox call, I don't have to respond to
> the remaining commands. Instead of "set messageCallback", I also tried
> loadStructCallback, but it didn't seem to help. In fact it's worse because
> for some reason property takes on the value "null".
> Also, for my own reference, how would I call temp_function with parameters?
>
>
The message callback returns two parameters. I think the first one
identifies the applet that send the message and the second one contains
the message that is send.
So if you would add "echo APPLET_DONE" at the end of your load script as
Bob proposed, you could check for this in your callback function:
function temp_function(app,msg) {
if (msg.match(/APPLET_DONE/)) {
property = getPropertyAsString("boundboxInfo");
}
}
(If you don't use the value of 'property' within 'temp_function' don't
forget to define it globally.)
You can see how this works for example here:
http://www.imb-jena.de/cgi-bin/3d_mapping.pl?CODE=1deh
Look at the function '_jmolMessageCallback'. I use it to log the
messages, look for some severe errors and display the number of
currently selected atoms.
Regards,
Rolf
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users