Proteopedia:DIY:Macros: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 21: | Line 21: | ||
<script> | <script> | ||
script /mc/ktheis.spt; | script /mc/ktheis.spt; | ||
if (~bobble); | if (~bobble); exit; ~bobble=false; else; bobble(); ~bobble=true; endif; | ||
</script> | </script> | ||
<text>Toggle Bobble on/off</text> | <text>Toggle Bobble on/off</text> | ||
Line 35: | Line 35: | ||
<script> | <script> | ||
script /mc/ktheis.spt; | script /mc/ktheis.spt; | ||
if (~bobble); | if (~bobble); exit; ~bobble=false; else; bobble(); ~bobble=true; endif; | ||
</script> | </script> | ||
<text>Toggle Bobble on/off</text> | <text>Toggle Bobble on/off</text> | ||
Line 41: | Line 41: | ||
</jmol> | </jmol> | ||
The <code><nowiki>bobble()</nowiki></code> part triggers the action. The <code><nowiki> | The <code><nowiki>bobble()</nowiki></code> part triggers the action. The <code><nowiki>exit</nowiki></code> ends the looping bobble. | ||
This example shows how to specify an item or items to act on by passing in a parameter. | This example shows how to specify an item or items to act on by passing in a parameter. |
Revision as of 05:27, 4 January 2021
Macros as a tool
Macros can be used in Proteopedia pages to call commonly used JSmol code. Macro functions can take parameters so that the code is general but can act on the specified item or items. Additional macros can be made.
This page is meant to be a resource for finding and using macros.
Defined MacrosThe currently listing of defined macro functions can be found at Proteopedia:Macros. Using MacrosIntegrating macro use into JSmol code is straightforward. This example doesn't require any parameter to act. It causes the structure shown to 'bobble()'. <jmol> <jmolLink> <script> script /mc/ktheis.spt; if (~bobble); exit; ~bobble=false; else; bobble(); ~bobble=true; endif; </script> <text>Toggle Bobble on/off</text> </jmolLink> </jmol>
You can try the result here:
The This example shows how to specify an item or items to act on by passing in a parameter.
Coding New MacrosAdvanced users who want to code additional macros can get a flavor for the JSmol operating behind the scenes and ideas on how they'd code their own by examining the code for macros already available. To view an example go the Proteopedia:Macros page and note that examples such as the 'bobble()' example include notes on how you import it using
|
|