Thanks, Bob,

OK, part of my problem is probably asynchrony.

In Javascript, I am doing

  jmolScript('altlocpivot = {altloc!=""}.altloc.all.pivot;' +
      'altlocpivotkeys = altlocpivot.keys;');

then

  altLocKeys = Jmol.evaluateVar(jmolApplet0, "altlocpivotkeys");
  alert(altLocKeys.length +" "+typeof(altLocKeys)+"\n"+altLocKeys);

The first time I load the browser, the alert reports a zero length string.
But if I click the alert again, I get the length 3 array.

Is there some way, from Javascript, to force the Jmol variables to be defined before the Jmol.evaluateVar() takes place?



On 9/1/15 7:10 PM, Robert Hanson wrote:
x = Jmol.evaluateVar(jmolApplet0, "altlocpivotkeys")


On Tue, Sep 1, 2015 at 5:58 PM, Eric Martz <ema...@microbio.umass.edu <mailto:ema...@microbio.umass.edu>> wrote:

    I have not been able to figure out how to get an array from Jmol
    applet into a Javascript array. For example, in the Jmol applet, I
    create a Jmol array:

    (Jmol applet contains 1bsz)
    (Jmol applet output in red)

    altlocpivot = {altloc!=""}.altloc.all.pivot;
    altlocpivotkeys = altlocpivot.keys;
    print altlocpivotkeys.type
    array
    print altlocpivotkeys
      A
      B
      C

    Now I want to get altlocpivotkeys into Javascript as an array.
    Perhaps something like

    x = getPropertyAsArray(jmolApplet0, "variableInfo altlocpivotkeys")

    (But Jmol says "getProperty ERROR". I think that I haven't been
    able to guess the syntax to specify the variable name. There is no
    example in the documentation.)

    With success, I am expecting the result in Javascript to be the
    equivalent of
    x = ["A", "B", "C"];
    so that
    x.length is 3
    x[1] is "B"

    Any help welcome.
    Thanks, Eric

    
------------------------------------------------------------------------------

    _______________________________________________
    Jmol-users mailing list
    Jmol-users@lists.sourceforge.net
    <mailto:Jmol-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/jmol-users




--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


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



------------------------------------------------------------------------------


_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to