PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/www/tags/NOV_07_2009/htdocs/42docs/users-guide/single-macros.html

#
HTML | 58 lines | 55 code | 3 blank | 0 comment | 0 complexity | a9047a2831bd5dbdb5c17bd9d3a0de64 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Single Execution Macros</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="jEdit 4.2 User's Guide"><link rel="up" href="macro-basics.html" title="Chapter 13. Macro Basics"><link rel="previous" href="beanshell-intro.html" title="Introducing BeanShell"><link rel="next" href="first-example.html" title="The Mandatory First Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Single Execution Macros</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="beanshell-intro.html">Prev</a> </td><th width="60%" align="center">Chapter 13. Macro Basics</th><td width="20%" align="right"> <a accesskey="n" href="first-example.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="single-macros"></a>Single Execution Macros</h2></div></div><div></div></div><p>
  2. As noted in <a href="organizing-macros.html" title="How jEdit Organizes Macros">the section called &#8220;How jEdit Organizes Macros&#8221;</a>, you can save a BeanShell
  3. script of any length as a text file with the <tt class="filename">.bsh</tt>
  4. extension and run it from the <span><b class="guimenu">Macros</b></span> menu.
  5. There are three other ways jEdit lets you use BeanShell quickly,
  6. without saving a script to storage, on a &#8220;<span class="quote">one time only</span>&#8221;
  7. basis. You will find them in the <span><b class="guimenu">Utilities</b></span> menu.
  8. </p><p>
  9. <span><b class="guimenu">Utilities</b></span>&gt;<span><b class="guisubmenu">BeanShell</b></span>&gt;<span><b class="guimenuitem">Evaluate BeanShell
  10. Expression</b></span> displays a text input dialog
  11. that asks you to type a single line of BeanShell commands. You can type
  12. more than one BeanShell statement so long as each of them ends with a
  13. semicolon. If BeanShell successfully interprets your input, a message
  14. box will appear with the return value of the last statement.
  15. </p><p>
  16. <span><b class="guimenu">Utilities</b></span>&gt;<span><b class="guisubmenu">BeanShell</b></span>&gt;<span><b class="guimenuitem">Evaluate For Selected
  17. Lines</b></span> displays a text input dialog that asks you to
  18. type a single line of BeanShell commands. The commands are evaluated
  19. for each line of the selection. In addition to the standard set of
  20. variables described in <a href="predefined-variables.html" title="Predefined Variables in BeanShell">the section called &#8220;Predefined Variables in BeanShell&#8221;</a>,
  21. this command defines the following:
  22. </p><div class="itemizedlist"><ul type="disc"><li><p><tt class="varname">line</tt> - the line number, from the
  23. start of the buffer. The first line is numbered 0.
  24. </p></li><li><p><tt class="varname">index</tt> - the line number, from the
  25. start of the selection. The first line is numbered 0.
  26. </p></li><li><p><tt class="varname">text</tt> - the text of the line.
  27. </p></li></ul></div><div class="informalexample"><p>
  28. Try typing an expression like <b class="userinput"><tt>(line + 1) + ": " + text</tt></b>
  29. in the <span><b class="guimenuitem">Evaluate For Selected Lines</b></span> dialog
  30. box. This will add a line number to each selected line beginning with
  31. the number <b class="userinput"><tt>1</tt></b>.
  32. </p></div><p>
  33. The BeanShell expression you enter will be evaluated and substituted in place of
  34. the entire text of a selected line. If you want to leave the line's current
  35. text as an element of the modified line, you must include the defined variable
  36. <b class="userinput"><tt>text</tt></b> as part of the BeanShell expression that you enter.
  37. </p><p>
  38. <span><b class="guimenu">Utilities</b></span>&gt;<span><b class="guisubmenu">BeanShell</b></span>&gt;<span><b class="guimenuitem">Evaluate Selection</b></span>
  39. evaluates the selected text as a BeanShell script and
  40. replaces it with the return value of the statement.
  41. </p><p>
  42. Using <span><b class="guimenuitem">Evaluate Selection</b></span> is an
  43. easy way to do arithmetic calculations inline while editing. BeanShell
  44. uses numbers and arithmetic operations in an ordinary, intuitive way.
  45. </p><div class="informalexample"><p>
  46. Try typing an expression like <b class="userinput"><tt>(3745*856)+74</tt></b>
  47. in the buffer, select it, and choose
  48. <span><b class="guimenu">Utilities</b></span>&gt;<span><b class="guisubmenu">BeanShell</b></span>&gt;<span><b class="guimenuitem">Evaluate
  49. Selection</b></span>. The selected text will be replaced by the
  50. answer, <b class="userinput"><tt>3205794</tt></b>.
  51. </p></div><div class="sidebar"><p class="title"><b>Console plugin</b></p><p>
  52. You can also do
  53. the same thing using the BeanShell interpreter option of the
  54. <span class="application">Console</span> plugin.
  55. </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="beanshell-intro.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="macro-basics.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="first-example.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Introducing BeanShell </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The Mandatory First Example</td></tr></table></div></body></html>