var xxx = ....

is local to whatever script contains it.

xxx = ....

is global.

On Mon, Sep 27, 2010 at 9:56 AM, Otis Rothenberger <[email protected]>wrote:

>  Bob,
>
> I'm having problems with save/restore state with models that originated
> with a load inline. The state script needs the original load string.
>
> I've been operating on the assumption that if my original onload script
> for the applet contains a var mod1 = "", then mod1 is global. If I do a
> load @mod1 with mod1 containing coordinate data, then a subsequent state
> save does, indeed, produce a script that indicates a need for mod1,
> @mod1 actually. If I haven't messed with mod1, shouldn't this still be
> around for a subsequent restore? I keep getting a can't find string data
> error on the restore.
>
>
it's supposed to switch to load DATA in that case,  I think, and explicitly
show the data.


> I've always been a bit confused about the role of "var" and Jmol Script
> globals. I use the above approach (initial declaration) to maintain
> variable  continuity between JavaScript functions, but this in not
> working on state restore. As an example of mod1 acting globally, the
> following duplication of a model works:
>
> function dupMod() {
>     if (moData) {return; }
>     var modTxt = "echo Copying model data...;mod1 = '" +
> jmolGetPropertyAsString("extractModel", "all") + "'";
>     jmolScript(modTxt); setTimeout("dupMod2()", 1000);
> }
>
>
right -- mod1 is global.

Easier, probably to use:

var modTxt = "echo Copying model data...;mod1 = getProperty('extractModel',
'all');echo;"

Also, I'm not seeing the point of the 1-second timeout for that dupMod2()
business, but if you are planning to do that, I would use jmolScriptWait,
not jmolScript. Then you know it's been executed.



function dupMod2() {
>     var modelTxt = "" + jmolGetPropertyAsString("extractModel", "all")
> + "";
>     var scpt = "var i = {*}.atomIndex.max + 1;var t =
> {*}.atomIndex.min;select within(branch, {atomIndex = i},
> {atomIndex=t});var x = {selected}.size;var y={*}.size;var z = y - x;";
>     scpt += "if (y > 40 || z != 0){echo This feature is limited to a
> single model with|less than 40 atoms.;delay 3;echo;}";
>     scpt += "else{var sz = 3;if (y > 4){sz = 4};if (y > 10){sz = 5};if
> (y > 30){sz = 7};set appendNew false;";
>     scpt += "select *;translateSelected {...@sz @sz 0};load APPEND '@mod1';";
>     scpt += "mod1='';hover off;}";
>     mepsData = false;
>     jmolScript(scpt);
>     doUFF(1);
>     setTimeout("lnkSwitch()", 1000);
> }
>
> Any suggestions?
>
>
OK, I need to unpack that:
I like the Javscript \ end-of-line continuator here...


function dupMod2() {
        var modelTxt = "" + jmolGetPropertyAsString("extractModel", "all");
        var scpt = "\
        var i = {*}.atomIndex.max + 1;\
        var t = {*}.atomIndex.min;\
        select within(branch, {atomIndex = i}, {atomIndex=t});\
        var x = {selected}.size;\
        var y={*}.size;\
        var z = y - x;\
        if (y > 40 || z != 0){\
            echo This feature is limited to a single model with|fewer than
40 atoms.;\
            delay 3;echo;\
        } else{\
            var sz = 3;\
            if (y > 4){sz = 4};\
            if (y > 10){sz = 5};\
            if (y > 30){sz = 7};\
            set appendNew false;\
              select *;translateSelected {...@sz @sz 0};\
            load APPEND '@mod1';\
            reset mod1;\
            hover off;\
        }";
        mepsData = false;
        jmolScript(scpt);
        doUFF(1);
        setTimeout("lnkSwitch()", 1000);
}


OK, there's a bug in saving the state from

load APPEND '@x'

load '@x' works just fine, but not with the append. OK. Jmol bug.

> Otis
>
> --
> Otis Rothenberger
> chemagic.com
>
>
>
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> 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
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to