Working with Scripts
The Pro Script module extends Mira's image processing capabilities using a scripting language based on the Lua language (see http://www.lua.org ). This provides a complete script processing engine that utilize or extend Mira's image and data processing capabilities or perform general computing tasks that do not involve Mira tools or images. For example, a script might perform tasks such as automating a complex imaging procedure, evaluating prototypes for different processing algorithms, computing a Taylor series and saving the results to a text file, or updating a semester calendar using rules based on the date of first class meeting.
Complete documentation on script functions, classes, methods, and other features, is found in the Mira MX x64 Script User's Guide which can be viewed in several ways:
Launch the online Mira MX x64 Script User's Guide in a browser
Open the PC-based Mira MX x64 Script User's Guide from your task menu or desktop icon.
For viewing, creating, and modifying scripts, Mira provides the Script Editor. The Script Editor is a text editor window that allows you to create, edit, and run scripts. The editor highlights different lua language elements according to rules that make the script syntax easier to understand, although the colors and fonts are not actually part of the script itself. This can be seen by viewing the script in a plain text editor. Scripts can be created and edited external to Mira sign various available editors, such as Notepad++ , which also supports syntax highlighting for Lua scripts. Since a lua script is simply a text file, scripts created outside Mira can be opened, edited, and executed from inside Mira.
From the Script Editor Window, scripts can be executed, or "run", using the[ ! ] button on the Window Toolbar. Scripts also can be executed using the same button on Mira's Main Toolbar and from the Script Manager.
Mira runs a script by either opening it directly from its text file or from text in the Script Editor. The script text is fed to the Lua engine, which compiles the text to byte code and executes it. The sections below describe how to create, open, save, and run scripts in Mira.
To create a new script, do one of the following. These actions open an empty Script Editor:
Execute the File > New command (Ctrl+N) and select Script Document as the new document type. Double click the document type or click [OK] to create the new script document.
Click the down-arrow on the button on the main toolbar, and select [Script Manager]. In the Script Manager
dialog, click [New].
To open a script from a file, do one of the following. These actions load the existing script into a Script Editor:
Use the File > Open command (Ctrl+O) and choose Lua Script File (*.lua) from the File Types drop box. Select the script file and click [Open].
Click the down-arrow on the button on the main toolbar, and select [Script Manager]. In the Script Manager
dialog, select a script and click the [Open] button.
Select a .lua file from the MRU (Most Recently Used) files list at the bottom of the File menu.
Drag a .lua file from Windows Explorer and drop it onto the Mira window.
Scripts are saved to text files with a lua file extension. You can choose to save
scripts in the ...\Mira Pro 8 x64\Scripts
folder tree or
anywhere in your file system. If you choose To save them outside
the ...\Mira Pro 8 x64\Scripts
folder tree, then they
will not be accessible from the Script Manager. To save a script,
use one of the following methods:
To Same file: Use the File >
Save command (Ctrl+S ) or the
button.
To Different file: Use the File > Save As command.
For detailed information about running a script, see Running Scripts. Essentially, there are 3 ways to run a script:
With the target Image window (or Plot window) as
the top-most window, click on the Main
Toolbar. This is critical if the script uses the CImageView:Attach method to access the top-most
image window.
From the Script Editor window, click .
From the Script Manager, click [Run].