Re: [Jmol-users] usage of jmolScript

2007-05-10 Thread Angel Herraez
Hola, Mauricio 

I've had this sort of trouble and I am pretty sure of the cause:

The applet takes some time to load, and the scripts run ahead of it. That's why 
if you put the 
"load" in jmolApplet() the molecule gets loaded, but the script is not. 
Probbaly if you reload 
the page, the script will work.

If you check the Javascript console for your browser, you will probbaly see 
"jmolApplet0 not 
found" or something of the sort.

The solution is 
a) put all the script inside jmolApplet()
or
b) have by some way the script being invoked by user action, not run as the 
page loads.

I'm not sure if using jmolScriptWait() will help here.

So, try

jmolInitialize("../jmol-11.0.1/");
jmolSetAppletColor("white");
jmolApplet(512, "load vdb/1stm.pdb;cpk off;wireframe off;cartoon on;color 
structure;",0);



> Can I call jmolScript anywhere I want in the page (inside html script tags or 
> inside another js file 
> ) after the applet 
> starts?

In principle it can go anywhere, but the key is "after the applet satrts", and 
you never know 
how long it will take to start. Tricky.



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] usage of jmolScript

2007-05-10 Thread Bob Hanson
Mauricio,

the space after "/jmol-" concerns me.
Bob Hanson

Mauricio Carrillo Tripp wrote:

> Hi,
>
> I've been looking for an answer on other posts with no luck, is this 
> code supposed to work?
>
>  
> jmolInitialize("../jmol- 11.0.1/");
> jmolSetAppletColor("white");
> jmolApplet(512);
> jmolScript("load vdb/1stm.pdb;cpk off;wireframe 
> off;cartoon on;color structure;",0);
>  
>
> If I include "load... ;... " on the jmolApplet it works fine, but as 
> it is it starts the applet but it doesn't load the molecule (no error 
> nor messages at all).

You should definitely see something in the Java console. Have you looked 
there? "jmolSetAppletColor("white") is pretty much deprecated. Just add

background white;

to your load script. There is no reason to use jmolScript right after 
jmolApplet. Better is to have:

jmolInitialize("../jmol- 11.0.1/");
jmolApplet(512, "background white;load vdb/1stm.pdb;cpk 
off;wireframe off;cartoon on;color structure;");

This presumes files are:


  parentdir/jmol- 11.0.1/JmolApplet0*.jar
  parentdir/thisdir/thispage.html
  parentdir/thisdir/vdb/1stm.pdb

That sound right?



> if I only load the molecule in jmolApplet, however, it loads it fine, 
> but "cpk off;..." in jmolScript is not run (no error nor messages at 
> all).
>
> Is there a special place/way to call jmolScript?
> Can I call jmolScript anywhere I want in the page (inside html script 
> tags or inside another js file  type="text/javascript">) after the applet starts?

yes and no: The first script you send is best sent from the jmolApplet() 
call itself, because then you can be certain that it is carried out at 
the correct time -- just after the applet is created.
You cannot use  
effectively "after the applet starts" because that would generally be 
the execution of JavaScript before the page document is complete. More 
likely you would have that just set up functions, and then later, say in 
hypertext links, have something like this:

do something


Check out the pages in 
http://www.stolaf.edu/academics/chemapps/jmol/docs/examples-11 and pages 
at http://jmol.sourceforge.net for examples.

Bob Hanson


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users