I mean, no one uses the script editor.

On Thu, Mar 22, 2012 at 7:25 PM, Robert Hanson <hans...@stolaf.edu> wrote:

> just ignore those. They are in the form of comments;  for syncing with the
> script editor and for command history - (which no one uses....)
>
>
> 2012/3/22 Adrià Cereto Massagué <adrian.cer...@urv.cat>
>
>> It works!
>>
>> I had to use 'set syncscript on' instead of 'sync script'.
>>
>> But when I enter any command from the Jmol console, in data[1] I have:
>> mycommand## EDITOR_IGNORE ## #NOSYNC;
>>
>> What does that '## EDITOR_IGNORE ## #NOSYNC;' thing mean? Am I doing
>> something wrong?
>>
>> Here's my code: https://gist.github.com/2158139
>>
>> Adrià
>>
>> El 22 de març de 2012 11:48, Adrià Cereto Massagué <adrian.cer...@urv.cat
>> > ha escrit:
>>
>> Thank you! I'll try the JmolStatusListener approach.
>>>
>>> I think it would be helpful for others to have this on the wiki.
>>>
>>> Regards,
>>>
>>> Adrià
>>>
>>> El 22 de març de 2012 3:39, Robert Hanson <hans...@stolaf.edu> ha
>>> escrit:
>>>
>>> Ah, I see. Let's work on this.....
>>>>
>>>> That's very interesting, and  it's  easy. Absolutely no hacking of Jmol
>>>> code. It's all ready for you.  A couple of options:
>>>>
>>>> 1) create a JmolScript function with the command name. That's your
>>>> starting point. it doesn't matter what this function does. maybe nothing.
>>>>
>>>> Function myCommand () {}
>>>>
>>>> Now the user can type;
>>>>
>>>> mycommand whatever whatever whatever....
>>>>
>>>> 2) Now, in your application's JmolStatusListener, you need to tell Jmol
>>>> that you are interested in listening for script commands and also process
>>>> those. That's called a SYNC callback. See the Export.java example:
>>>>
>>>> class MyStatusListener implements JmolStatusListener {
>>>>
>>>>   public boolean notifyEnabled(EnumCallback type) {
>>>>     // indicate here any callbacks you will be working with.
>>>>     // some of these flags are not tested. See
>>>> org.jmol.viewer.StatusManager.java
>>>>     switch (type) {
>>>>     case SYNC:
>>>>          return true;
>>>>     default:
>>>>          return false;
>>>>     }
>>>>   }
>>>>
>>>>   @SuppressWarnings("incomplete-switch")
>>>>   public void notifyCallback(EnumCallback type, Object[] data) {
>>>>     switch (type) {
>>>>     case SYNC:
>>>>      ...
>>>>       break;
>>>>     }
>>>>   }
>>>>
>>>>
>>>> now issue the Jmol script command;
>>>>
>>>> sync script
>>>> sync ON
>>>>
>>>> and watch every script command come your way.
>>>>
>>>> The command from Viewer.StatusManager will be this:
>>>>
>>>>   void syncSend(String script, String appletName, int port) {
>>>>     if (port != 0 || notifyEnabled(EnumCallback.SYNC))
>>>>       jmolCallbackListener.notifyCallback(EnumCallback.SYNC,
>>>>           new Object[] { null, script, appletName,
>>>> Integer.valueOf(port) });
>>>>   }
>>>>
>>>> So the script command will appear as data[1].
>>>>
>>>> I realize this is not at all obvious. But it is very powerful and
>>>> flexible.
>>>>
>>>> Another option would be within your function to use the JAVASCRIPT
>>>> command. That will return a string value to Jmol. And, come to think of it,
>>>> we could set that up to return anything in the form of a ScriptToken. So
>>>> for example:
>>>>
>>>>
>>>> Function getCharges (atoms) {
>>>>     return  javascript("exec getES: " + atoms.label("%i %e %[xyz]")
>>>> }
>>>>
>>>> Now if in Jmol the user enters:
>>>>
>>>> print getcharges({helix})
>>>>
>>>> they will see the result after your end processes that command. Of
>>>> course, if you want, rather than just returning the result, you could do
>>>> anything you want with  it.
>>>>
>>>> More possibilities: Maybe you would  like to connect with Jmol over a
>>>> socket? We do that in the molecular playground. It works great, and you can
>>>> receive and send commands to Jmol using the SYNC command with a port 
>>>> number:
>>>>
>>>> SYNC -30000
>>>>
>>>> Now Jmol is listening on port 30000 for NIOS calls. Now you can connect
>>>> a client and off you go.
>>>>
>>>> more about that if you are interested. No documentation on that I think.
>>>>
>>>> Bob
>>>>
>>>>
>>>>
>>>> Bob
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> listen for your command and do anything with it you want to.
>>>>
>>>> The "registering" in jmol is just the definition of
>>>>
>>>> You  would  just ignore all the commands you  aren't interested in
>>>> processing.
>>>>
>>>>
>>>>
>>>> 2012/3/21 Adrià Cereto Massagué <adrian.cer...@urv.cat>
>>>>
>>>>>
>>>>>
>>>>> El 21 de març de 2012 19:31, Robert Hanson <hans...@stolaf.edu> ha
>>>>> escrit:
>>>>>
>>>>> That's Jmol script, not JavaScript. Yes, essentially exactly like
>>>>>> pyMol. You can write any macro you want.
>>>>>>
>>>>>
>>>>> I didn't explain well.
>>>>> I can implement some of that functionality using JmolScript, but not
>>>>> everything I want.
>>>>> I would like to map commands to, or directly call ,Java (not
>>>>> JavaScript nor JmolScript) functions from the Jmol console.
>>>>> With pymol one can register any python function as a command available
>>>>> from pymol's console.
>>>>> Here it's explained: http://www.pymolwiki.org/index.php/Extend
>>>>>
>>>>>
>>>>> Is there something similar in Jmol?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> 2012/3/21 Adrià Cereto Massagué <adrian.cer...@urv.cat>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> El 21 de març de 2012 1:45, Robert Hanson <hans...@stolaf.edu> ha
>>>>>>> escrit:
>>>>>>>
>>>>>>> Custom commands can be simply set up by defining a function with
>>>>>>>> that command name. is that what you mean -- sort of a macro?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> function colorMeBlue(atoms) {
>>>>>>>>
>>>>>>>>   color @atoms blue
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> colorMeBlue {helix}
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Thank you. I have some commands I can implement in JmolScript, and
>>>>>>> therefore defien as functions,
>>>>>>> but I would like to call or execute an external Java method. Can it
>>>>>>> be done?
>>>>>>>
>>>>>>> In PyMol it is possible to map a python function to a script
>>>>>>> command. Is there something similar in Jmol?
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/3/20 Adrià Cereto Massagué <adrian.cer...@urv.cat>
>>>>>>>>
>>>>>>>>>  Hello,
>>>>>>>>>
>>>>>>>>> I am new to Jmol, and I am developing an application which relies
>>>>>>>>> on it (the Integration.java example has been very useful)
>>>>>>>>>
>>>>>>>>> I want to have some custom commands available from the scripting
>>>>>>>>> console. Is there an easy way for doing so?
>>>>>>>>>
>>>>>>>>> I have tried extending AppConsole and overriding the
>>>>>>>>> enterPressed() method and checking AppConsole.text for the last line, 
>>>>>>>>> but
>>>>>>>>> then I have no way no clear the custom command from the console 
>>>>>>>>> unless i
>>>>>>>>> call super.enterPressed(), which prints a script error about 
>>>>>>>>> (obviously)
>>>>>>>>> not recognizing the command.
>>>>>>>>>
>>>>>>>>> Thank you in  advance,
>>>>>>>>>
>>>>>>>>> Adrià
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> *Adrià Cereto Massagué*
>>>>>>>>> Ph.D Student
>>>>>>>>> Nutrigenomics Research Group
>>>>>>>>> Biochemistry and Biotechnology Department
>>>>>>>>> Building N4, Campus Sescelades
>>>>>>>>> Universitat Rovira i Virgili
>>>>>>>>> Tarragona, Catalonia
>>>>>>>>>
>>>>>>>>> Languages: Català, Español, English, Français, Deutsch, Português
>>>>>>>>>
>>>>>>>>> Nota 
>>>>>>>>> importante<http://www.gnu.org/philosophy/no-word-attachments.es.html>|
>>>>>>>>>  Important
>>>>>>>>> Notice <http://www.gnu.org/philosophy/no-word-attachments.html>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> This SF email is sponsosred by:
>>>>>>>>> Try Windows Azure free for 90 days Click Here
>>>>>>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>>>>>> _______________________________________________
>>>>>>>>> Jmol-users mailing list
>>>>>>>>> Jmol-users@lists.sourceforge.net
>>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> This SF email is sponsosred by:
>>>>>>>> Try Windows Azure free for 90 days Click Here
>>>>>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Jmol-users mailing list
>>>>>>>> Jmol-users@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> This SF email is sponsosred by:
>>>>>>> Try Windows Azure free for 90 days Click Here
>>>>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>>>> _______________________________________________
>>>>>>> Jmol-users mailing list
>>>>>>> Jmol-users@lists.sourceforge.net
>>>>>>> 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
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> This SF email is sponsosred by:
>>>>>> Try Windows Azure free for 90 days Click Here
>>>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>>>
>>>>>> _______________________________________________
>>>>>> Jmol-users mailing list
>>>>>> Jmol-users@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> This SF email is sponsosred by:
>>>>> Try Windows Azure free for 90 days Click Here
>>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>> _______________________________________________
>>>>> Jmol-users mailing list
>>>>> Jmol-users@lists.sourceforge.net
>>>>> 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
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> This SF email is sponsosred by:
>>>> Try Windows Azure free for 90 days Click Here
>>>> http://p.sf.net/sfu/sfd2d-msazure
>>>>
>>>> _______________________________________________
>>>> Jmol-users mailing list
>>>> Jmol-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>>
>>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here
>> http://p.sf.net/sfu/sfd2d-msazure
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> 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
>



-- 
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
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to