Working with Scripts
This topic describes how to open, edit, create, run, and save scripts. Most of these tasks involve using a Script Editor Window, which is a text editor that highlights the different language elements according to patterns and rules, with several styles to display different types of syntax. This highlighting is for visual purposes only and is not part of the script text itself. You will also read about the Script Manager, which is an older feature that is more cumbersome and less versatile than the Script Editor.
Note: This User's Guide contains many sample scripts and script fragments which you can run by inserting them into Mira. See Running Scripts shown in the User's Guide.
To open a script from a file, open the file into a Script Editor Window:
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.
There are several ways to run a script:
With the script in the top-most view window on the Mira desktop, click on Mira's main toolbar.
From a Script Editor Window, click on its top toolbar.
From the Script Manager, click [Run].
From a Script Editor Window, call one of the attach... or attachlist... script commands to attach a view window appearing on the desktop.
From a view window, use the Execute Script menu command to launch a script using the view window's data or for other purposes. This is available for Image Windows, Plot Windows, Grid Windows (Report Windows), and grid measurement panes attached to Image Windows. See the description of the CImageView, CPlotView, and CGridView classes.
To edit a script, simply modify it in the Script Editor Window. Outside of Mira, you can also edit a lua script file using a simple editor like Notepad or the syntax highlighting editor Notepad++. Do not use a word procesing editor such as MS Word, as these editors insert special codes into the script file. Also see Script Editor Window.
To create a new script in a Script Editor Window, do one of the following:
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].
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:
Save to the same file using the File > Save command (Ctrl+S) or the button.
Save to a different file using the File > Save As command.
Running Scripts shown in the User's Guide
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.