On 04/30/2012 11:43 AM, eric henon wrote:
> Hi all,
>
> I need to define scripts spt
> that could be called with different
> parameters depending on when it is called
> in my jmol application. These parameters
> are Jmol variables.
>
> The problem is that, when defining a function,
> etiher in my jmol application or in Jmol.js,
> parameters are considered as javascript variables, and
> I cannot get back values from javascript variables to Jmol variables.
>
>
> The jmolEvaluate function allows for passing information
> from Jmol to Javascript, but what about the reverse action ?
>
> In other words, how to define "jmol functions" ?
>
I am not sure if I understood your problem correctly but it shouldn't be
a problem to pass parameters to a Jmol function call (see the Jmol
scripting documentation:
http://chemapps.stolaf.edu/jmol/docs/#functionsuser-definedfunctions).
Example Jmol function:
function my_print(my_text) {
echo my_text;
}
Example Javascript call:
var my_javascript_text = "passed from javascript";
jmolScript("my_print(" + my_javascript_text + ")");
I havn't tested this myself but would expect it to work.
Depending of the type of parameters of the Jmol function you might have
to adapt them to being called from javascript.
If you would have for example a "point" variable (see
http://chemapps.stolaf.edu/jmol/docs/#jmolmathjmolvariables) in Jmol
script ("pt={3.2,3.3,3.4}") it might be necessary to pass the x,y and z
value as separate paramters 'x', 'y', 'z' instead of as the single
parameter "{3.2,3.3,3.4}".
Regards,
Rolf
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers