Working with Scripts
The Mira MX Script language extends Mira's image processing capabilities using a scripting language. This module is available as an optional item for the Mira platform. The Mira MX Script Language is an extension of the Lua language (see http://www.lua.org) to provide a complete script processing engine that can be used to extend Mira's image and data processing capabilities and to perform general types of computing tasks independent of images.
For viewing, creating, and modifying scripts, Mira provides the Script Editor. The Script Editor is a special kind of text editor that highlights the different language elements according to patterns and rules. The script editor uses several styles to display different types of syntax. This syntax highlighting makes the script more human-readable but it does not actually affect the script text itself. Scripts can be executed, or "run", using the [ ! ] button on the Script Editor Toolbar and the Main Toobar, or from the Script Manager.
When running a script, Mira loads the text directly from a file or from the Script Editor. This 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.
Note: This User's Guide contains many sample scripts and scripts which you can run by inserting them into Mira. See Running Scripts listed in the User's Guide.
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 ]\Scripts folder tree or anywhere in your file system. If you choose to save them outside the [Mira ]\Scripts folder tree, then they will not be accessible from the Script Manager. To save a script, use one of the following methods:
To the Same
file: Use the File > Save command (Ctrl+S) or the
button.
To a
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].