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 <[email protected]> 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
>
>
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for
> Conference
> attendees to learn about information security's most important issues
> through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


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
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to