Some general debugging suggestions.

-- combine Jmol.script calls when possible. It really doesn't matter, but
there is no advantage to sending multiple calls. They just go on a queue
one after another.

-- realize Jmol.script is an asynchronous interface. It will not execute
immediately. The applet may not even have finished initialization when this
is sent. If you need immediate action, use Jmol.scriptWait or
Jmol.evaluate. But avoid those if you can. Callbacks are really the
"modern" way to go.

-- set up your callbacks any time, but within Info is the easiest. It can
be by setting Info.xxxxxCallback: yyyy   or by script:"set xxxxxCallback
'myfuncName'". Either way is the same.

-- when developing, provide yourself with a link to

 Jmol.showInfo(jmolObject, true)

  so that you can see what problems there might be.

-- Also, set

Info.addSelectionOptions = true

This give you textbox under the applet. That search box also accepts
commands. Just prefix your commands with "!". One very handy command is

 !JSCONSOLE

-- Also, as needed, replace JSmol.min.js with js/JSmol.full.js, and
possibly one or more of j2s/core/xxxcore.z.js with js/xxxcore.js so that
you are working with unminified files. It's way easier to debug.

Let's go through a debugging scenario:

-- I think messageCallback is broken. I'm seeing this in the JSmol
javascript console:

myMesssageCallback failed TypeError: b is not a function

This changes to

myMesssageCallback failed TypeError: o is not a function

When I copy js/core.js to j2s/core/core.z.js. I know, not a big help, but
it's a start.

I could also have tried

    script: "load $caffeine;set messageCallback 'alert' "

which at least sends me a message from the callback method showing me that
the problem is definitely at the point of making the call to my method.

So let's debug this....

In core.js I find the following, searching for the keyword "failed":








*var o = window[tokens[0]];for (var i = 1; i < tokens.length; i++)o =
o[tokens[i]];for (var i = 0; i < data.length; i++)data[i] &&
data[i].booleanValue && (data[i] = data[i].booleanValue());return
o(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);} catch
(e) { System.out.println(callback + " failed " + e); }*
There's the source of that message, for sure.

I add a couple of alerts:


*alert(tokens[0])*var o = window[tokens[0]];
for (var i = 1; i < tokens.length; i++) *{*

*alert (o + " " + tokens[i])*o = o[tokens[i]];
*}*
for (var i = 0; i < data.length; i++)
data[i] && data[i].booleanValue && (data[i] = data[i].booleanValue());
return o(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);
} catch (e) { System.out.println(callback + " failed " + e); }

Starting 'er up again... I get my message.
Darned it! I spelled *myMessageCallback  *wrong!

Fixed that. Try again... now I get this message in the Jmol JavaScript
console:


*myMessageCallback failed ReferenceError: message is not defined*
Oh, oh, that's more serious. Looks like a Jmol bug. No, wait, it's on my
page. I had written:

function myMessageCallback(app,msg) {
  alert(app + " " + message)
}

instead of

function myMessageCallback(app,msg) {
  alert(app + " " + msg)
}

Oddly enough, Jmol has trapped *my* JavaScript error! Fixing that, all is
working. It's interesting to add a few parameters and see what they give:

function myMessageCallback(app,msg, c, d, e) {
  alert(app + " " + msg + " c=" + c + " d=" + d + " e=" + e)
}

--- oh, I see... that fourth parameter tells me what type of message I'm
getting... I guess I'll only look at messages when d===0...

That's the idea, anyway. Not too bad, huh?

:)

Bob
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to