lExecutor

lExecutor is a Lua 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.

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 main() 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.

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 File->Save Output (Ctrl + S) and choose the location to save the file to. When you save the log lExecutor will clear the output.

lExecutor can also open new files and load them to execute without always having to restart the application. To do this you use File->Open (Ctrl+O) and select the file you want to open.

Author:

Ryan Pusztai

Release: 1.00 <12/05/2008>

Note:

    When a file is loaded lExecutor 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).

lExecutor:

    To use lExecutor you need to write scripts in Lua. You can find out more about Lua here:

  • Lua manual
  • Programming in Lua First Edition (book)

Usage:

    lExecutor.wlua [script [args]]

    Options:

    • script
        file path to a Lua script to load when started. It must exist.
    • args
        arguments to pass to the loaded script. Not to lexecutor

General Information:

    Script initialization and using a main():
      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 main(). This is simply done as a main entry point into your application. If the global function main() is missing lExecutor will just execute the entire script when 'Execute' is pressed.
       -- Initialization code here
      APP_NAME = "Simple lExecutor Example"
      -- Code that is ran as soon as lExecutor has loaded this script.
      port = lExecutor.Prompt( "What COM port?" )

      -- Main entry point
      -- This is ran every press of 'Execute' in lExecutor.
      function main()
          print( "Hi from main()" )
          print( "Opening COM port", port )
      end

      -- Checking to see if lExecutor is running this script.
      -- If it is not then we still want the script to run completely,
      -- so call main()
      if not _LEXECUTOR then
          main()
      end
    Script parameters:
      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 arg. 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.
       print( "Script that is loaded: ", arg[0] )
      print( "Number of arguments sent to the script: ", #arg )
      print( "Unpacked arguments: ", unpack( arg ) )

Functions

lExecutor.Prompt (message) This function will allow you to take input from the user.
lExecutor.SetPassFailStatus (isPassed) Display a pass or fail status to the user running the script.
print (...) This overrides the default print() and allows the loaded script to display feedback to the user in the GUI.

Tables

APP_NAME Use this in the calling app to overwrite the windows title that is displayed.
_LEXECUTOR This symbol is defined so that scripts can be written to know if lExecutor is running the script.


Functions

lExecutor.Prompt (message)
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.

Parameters:

  • message: {string} Message to display to the user.

Return value:

    {string} The value entered by the user.
lExecutor.SetPassFailStatus (isPassed)
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. So call this in your initialization section to make display before the first time a user clicks 'Execute'.

Parameters:

  • isPassed: {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. It defaults to false.
print (...)
This overrides the default print() and allows the loaded script to display feedback to the user in the GUI.

Parameters:

  • ...: {varies} Message to display to the user.

Tables

APP_NAME
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.

Example:

 APP_NAME = "My Cool App" 
_LEXECUTOR
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 main() function, so that lExecutor can be the only one to call it. Ex.

Example:

 function main()
    print( "Hello World" )
end

-- Now we need to automatically run the main() function when
-- anywhere other then lExecutor.
if not _LEXECUTOR then main() end

Valid XHTML 1.0!