VERY good! comments below....

On Tue, Apr 5, 2011 at 8:41 AM, Michael Marden <michael.mar...@inserm.fr>wrote:

>  Progress on piloting Jmol from Visual Basic (VB)via WebBrowser
> Considering the framework:
> VB - HTML elements - Jmol functions
>
> I switched to VB.NET for further testing, as that is the modern system,
> and the few fragments of information concerning data retrieval were relative
> to the NET system.
>
> After much time spent on “formatting”, the following give signs of life.
>
> VB to Jmol:
> WebBrowser1.Document.InvokeScript("jmolScript", {"load heme.pdb"})
>

nice. Definitely the way to go.


>
> Jmol to VB (info retrieval)
> StringA = WebBrowser1.Document.InvokeScript("jmolEvaluate", {"5 + 6"})
> StringA = WebBrowser1.Document.InvokeScript("jmolGetPropertyAsString",
> {"atomInfo", "atomno=1"})
> StringA = WebBrowser1.Document.InvokeScript("jmolGetPropertyAsString",
> {"fileName"})
>
>
ah, so you CAN get a return from functions. Good. jmolScriptWait will also
work then.


> This is good news, although first attempts at recovering an array did not
> work.  The methods requiring explicit code for “callback” or “common
> functions” are apparently not necessary.
>
>

callbacks do serve a purpose -- responding to user atom picking and knowing
that a file is loaded, for example.



>
>
> Curious, I went back to VB6 to try again the component that failed (Jmol to
> VB)
>      This did work:
> StringA = WebBrowser1.Document.parentWindow.jmolEvaluate("3 + 5")
>        But similar commands using GetProperty did not:
> StringA =
> WebBrowser1.Document.parentWindow.jmolGetPropertyAsString("FileName")
>        returns “zapped”
> StringA =
> WebBrowser1.Document.parentWindow.jmolGetPropertyAsString("atomInfo",
> "atomno=1")
>        returns “*Vector[0]”
>
>
Then those are working, too. It looks like you just don't have a file loaded
into Jmol.


Try:

StringA =
WebBrowser1.Document.parentWindow.jmolGetPropertyAsString("appletInfo")

which does not depend upon a file being loaded.


> further remarks (tested with NET)
> a) There is a timing problem. If I load “Mb” then run a subroutine with
> load “heme” followed
> by jmolGetPropertyAsString("FileName"), it returns the “Mb” name. A repeat
> of the sub correctly returns “heme”
>

That's because jmolScript() runs asynchronously --  it queues the script but
does not immediately run it. You could try jmolScriptWait() instead.


> b) jmolGetPropertyAsString("atomInfo", "atomno=1") is ok for Mb, but null
> for heme
>

again, probably just a timing issue.


> c) I wanted to try jmolGetPropertyAsString of the Spin state (on or off)
> but could not find it.
>

jmolGetPropertyAsString("stateInfo")

can be parsed for spin state. Also, check out the _? variables.

$ show _?
  _animating = false;
  _applet = false;
  _atomhovered = -1;
  _atompicked = -1;
  _currentfilenumber = 1;
  _currentmodelnumberinfile = 1;
  _depthplane = "{68.08549 -2.7234198E-6 -2.7234198E-6 249.0}";
  _filetype = "SpartanSmol";
  _firstframe = "1.1";
  _frameid = 1000001;
  _height = 498;
  _lastframe = "1.31";
  _loadpoint = 3;
  _memory = "7.1/12.0";
  _modelfile = "C:/temp/c6h6.smol";
  _modelname = "Energy=-229.41942 KJ";
  _modelnumber = "1.1";
  _multitouchclient = false;
  _multitouchserver = false;
  _navigating = false;
  _nprocessors = 2;
  _pickinfo = "";
  _signedapplet = false;
  _slabplane = "{68.08549 -2.7234198E-6 -2.7234198E-6 -249.0}";
  _spinning = false;
  _usecommandthread = false;
  _version = 1201042;
  _width = 500;


You  can get those with jmolEvaluate:

StringA = WebBrowser1.Document.parentWindow.jmolEvaluate("_spinning")


Now see if that window.external call will work to run a VB command from the
JavaScript on the page. Then you will be all set with callbacks. For
example:

jmolScript("set loadStructCallback 'jsLoadCallback'")

function
jsLoadCallback(app,strUrl,strFilename,strTitle,strError,intState,strPrevFrame,strThisFrame)
{
  window.external.vbCallback(strFilename,strError,intState)
}


and have the vbCallback function defined in your VB code.  Might work! I
can't remember if VB.net has something like the Java "public" keyword.

Bob

-- 
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
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to