PageRenderTime 69ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/lexecutor/lExecutor.html

http://luapack.googlecode.com/
HTML | 258 lines | 122 code | 133 blank | 3 comment | 0 complexity | 6ffc029f3c28bdec875b4c3ef20612dd MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, AGPL-3.0, LGPL-2.0, LGPL-3.0, BSD-3-Clause, ISC
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <title>Reference</title>
  6. <link rel="stylesheet" href="luadoc.css" type="text/css" />
  7. <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
  8. </head>
  9. <body>
  10. <div id="container">
  11. <div id="product">
  12. <div id="product_logo"></div>
  13. <div id="product_name"><big><b></b></big></div>
  14. <div id="product_description"></div>
  15. </div> <!-- id="product" -->
  16. <div id="main">
  17. <div id="navigation">
  18. <h1>LuaDoc</h1>
  19. <ul>
  20. <li><strong>lExecutor</strong></li>
  21. </ul>
  22. <!-- Module list -->
  23. <!-- File list -->
  24. </div><!-- id="navigation" -->
  25. <div id="content">
  26. <h1>Module <code>lExecutor</code></h1>
  27. <p>lExecutor is a <a href="http://lua.org">Lua</a> application that allows users to run there console based scripts in a user interface. It is completely general purpose and uses 'print()' and 'Prompt()' to get messages to the GUI. It is very simple and exposes only a couple of variables and functions to aid in keeping your scripts simple and not written just to work in lExecutor.<br /> <br /> lExecutor has a very simple user interface that has a menu, an output log, an execute button, and a continuous run checkbox. You can open lExecutor just by launching it and then if no script was passed on its command line it will prompt for a file to run. After that the user just clicks the 'Execute' button each time they want to run the script, starting at the <code>main()</code> function. If the user wants to repeatedly run the script over and over, just clicking the 'Continuous' checkbox and then the 'Execute' button. The 'Continuous' checkbox is located next to the 'Execute' button. When you are done running it is continuous mode just click the 'Continuous' checkbox, to remove the check, and it will stop executing.<br /> <br /> lExecutor can also save the output to a text file so that you can review and have record of all that occured in that session. To save the output to a text file use <code>File->Save Output (Ctrl + S)</code> and choose the location to save the file to. When you save the log lExecutor will clear the output.<br /> <br /> lExecutor can also open new files and load them to execute without always having to restart the application. To do this you use <code>File->Open (Ctrl+O)</code> and select the file you want to open. </p>
  28. <p><b>Author:</b>
  29. <table class="authors_list">
  30. <tr><td class="name"><a href="mailto:rpusztai@gmail.com">Ryan Pusztai</a></td></tr>
  31. </table>
  32. </p>
  33. <p><b>Release:</b> 1.01 <04/07/2010> <h2>Note:</h2> <ul>When a file is loaded <code>lExecutor</code> will set the current working directory to the loaded scripts directory. Make sure your paths in your scripts are relative to the top level script (the script you are running). </ul> <h2>lExecutor:</h2> <ul> To use lExecutor you need to write scripts in Lua. You can find out more about Lua here:<br /><br /> <li><a href="http://lua.org/manual/">Lua manual</a></li> <li><a href="http://www.lua.org/pil/">Programming in Lua</a> &#x2013; First Edition (book)</li> </ul> <h2>Usage:</h2> <ul> <code>lExecutor.wlua [script [args]]</code> <h4>Options:</h4> <ul> <li><code>script</code> <ul>file path to a Lua script to load when started. It must exist.</ul></li> <li><code>args</code> <ul>arguments to pass to the loaded script. Not to lexecutor</ul></li> </Ul> </ul> <h2>General Information:</h2> <ul> <b>Script initialization and using a <code>main()</code>:</b> <ul> The general idea that lExecutor uses is the idea that any code that is not in a fuction is ran as initialization code for your script. Then lExecutor calls a global function named <code>main()</code>. This is simply done as a main entry point into your application. If the global function <code>main()</code> is missing lExecutor will just execute the entire script when 'Execute' is pressed. <pre class="example"> -- Initialization code here<br /> APP_NAME = "Simple lExecutor Example"<br /> -- Code that is ran as soon as lExecutor has loaded this script.<br /> port = lExecutor.Prompt( "What COM port?" )<br /> <br /> -- Main entry point<br /> -- This is ran every press of 'Execute' in lExecutor.<br /> function main()<br /> &nbsp; &nbsp; print( "Hi from main()" )<br /> &nbsp; &nbsp; print( "Opening COM port", port )<br /> end<br /> <br /> -- Checking to see if lExecutor is running this script.<br /> -- If it is not then we still want the script to run completely,<br /> -- so call main()<br /> if not _LEXECUTOR then<br /> &nbsp; &nbsp; main()<br /> end </pre> </ul> </ul> <ul> <b>Script parameters:</b> <ul> When running a script you can access the command line parameters passed to the script (see above in the 'Usage' section) in a table called <code>arg</code>. The zero index always has the full file name of the running script. It also contains the rest of the parameters passed in as a normal Lua table. <pre class="example"> print( "Script that is loaded: ", arg[0] )<br /> print( "Number of arguments sent to the script: ", #arg )<br /> print( "Unpacked arguments: ", unpack( arg ) ) </pre> </ul> </ul>
  34. </p>
  35. <h2>Functions</h2>
  36. <table class="function_list">
  37. <tr>
  38. <td class="name" nowrap><a href="#lExecutor.ClearLog">lExecutor.ClearLog</a>&nbsp;()</td>
  39. <td class="summary">Clears the log </td>
  40. </tr>
  41. <tr>
  42. <td class="name" nowrap><a href="#lExecutor.Prompt">lExecutor.Prompt</a>&nbsp;(message)</td>
  43. <td class="summary">This function will allow you to take input from the user.</td>
  44. </tr>
  45. <tr>
  46. <td class="name" nowrap><a href="#lExecutor.SetPassFailStatus">lExecutor.SetPassFailStatus</a>&nbsp;(isPassed, show)</td>
  47. <td class="summary">Sets the pass/fail status indicator to the specified state.</td>
  48. </tr>
  49. <tr>
  50. <td class="name" nowrap><a href="#print">print</a>&nbsp;(...)</td>
  51. <td class="summary">This overrides the default <code>print()</code> and allows the loaded script to display feedback to the user in the GUI.</td>
  52. </tr>
  53. </table>
  54. <h2>Tables</h2>
  55. <table class="table_list">
  56. <tr>
  57. <td class="name" nowrap><a href="#APP_NAME">APP_NAME</a></td>
  58. <td class="summary">Use this in the calling app to overwrite the windows title that is displayed.</td>
  59. </tr>
  60. <tr>
  61. <td class="name" nowrap><a href="#_LEXECUTOR">_LEXECUTOR</a></td>
  62. <td class="summary">This symbol is defined so that scripts can be written to know if lExecutor is running the script.</td>
  63. </tr>
  64. </table>
  65. <br/>
  66. <br/>
  67. <h2><a name="functions"></a>Functions</h2>
  68. <dl class="function">
  69. <dt><a name="lExecutor.ClearLog"></a><strong>lExecutor.ClearLog</strong>&nbsp;()</dt>
  70. <dd>
  71. Clears the log
  72. </dd>
  73. <dt><a name="lExecutor.Prompt"></a><strong>lExecutor.Prompt</strong>&nbsp;(message)</dt>
  74. <dd>
  75. This function will allow you to take input from the user. This function will stop the execution of your script to let the user respond.
  76. <h3>Parameters:</h3>
  77. <ul>
  78. <li>
  79. <code><em>message</em></code>: {string} Message to display to the user.
  80. </li>
  81. </ul>
  82. <h3>Return value:</h3>
  83. <ul>{string} The value entered by the user.</ul>
  84. </dd>
  85. <dt><a name="lExecutor.SetPassFailStatus"></a><strong>lExecutor.SetPassFailStatus</strong>&nbsp;(isPassed, show)</dt>
  86. <dd>
  87. Sets the pass/fail status indicator to the specified state. Use this to display a pass or fail status to the user running the script. This function will show the pass/fail status indicator the first time it is called.
  88. <h3>Parameters:</h3>
  89. <ul>
  90. <li>
  91. <code><em>isPassed</em></code>: {bool} [DEF] If true then the indicator will display "PASS" and the background will be green. If false, then it will display "FAIL" and the background will be red.
  92. </li>
  93. <li>
  94. <code><em>show</em></code>: {bool} [DEF] If true then the indicator will display, else if false it will not show. This defaults to true.
  95. </li>
  96. </ul>
  97. </dd>
  98. <dt><a name="print"></a><strong>print</strong>&nbsp;(...)</dt>
  99. <dd>
  100. This overrides the default <code>print()</code> and allows the loaded script to display feedback to the user in the GUI.
  101. <h3>Parameters:</h3>
  102. <ul>
  103. <li>
  104. <code><em>...</em></code>: {varies} Message to display to the user.
  105. </li>
  106. </ul>
  107. </dd>
  108. </dl>
  109. <h2><a name="tables"></a>Tables</h2>
  110. <dl class="table">
  111. <dt><a name="APP_NAME"></a><strong>APP_NAME</strong></dt>
  112. <dd>Use this in the calling app to overwrite the windows title that is displayed. This just allows a bit more customization of the GUI. It must be a string and it must be a global declaration. <h4>Example:</h4> <pre class="example"> APP_NAME = "My Cool App" </pre><br /><br />
  113. </dd>
  114. <dt><a name="_LEXECUTOR"></a><strong>_LEXECUTOR</strong></dt>
  115. <dd>This symbol is defined so that scripts can be written to know if lExecutor is running the script. This can be helpful so that you can write your script once and have it work in the console as well as lExecutor. A common use for this would be to not automatically call your Lua scripts <code>main()</code> function, so that lExecutor can be the only one to call it. Ex. <h4>Example:</h4> <pre class="example"> function main()<br /> &nbsp; &nbsp; print( "Hello World" )<br /> end<br /> <br /> -- Now we need to automatically run the main() function when<br /> -- anywhere other then lExecutor.<br /> if not _LEXECUTOR then main() end </pre><br /><br />
  116. </dd>
  117. </dl>
  118. </div> <!-- id="content" -->
  119. </div> <!-- id="main" -->
  120. <div id="about">
  121. <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
  122. </div> <!-- id="about" -->
  123. </div> <!-- id="container" -->
  124. </body>
  125. </html>