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.

Opening Existing Scripts

To open a script from a file, open the file into a Script Editor Window:

bullet.gif    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].

bullet.gif    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.

bullet.gif    Select a .lua file from the MRU (Most Recently Used) files list at the bottom of the File menu.

bullet.gif    Drag a .lua file from Windows Explorer and drop it onto the Mira window.

Running Scripts

There are several ways to run a script:

bullet.gif    With the script in the top-most view window on the Mira desktop, click on Mira's main toolbar.

bullet.gif    From a Script Editor Window, click on its top toolbar.

bullet.gif    From the Script Manager, click [Run].

bullet.gif    From a Script Editor Window, call one of the attach... or attachlist... script commands to attach a view window appearing on the desktop.

bullet.gif    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.

Editing Scripts

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.

Creating New Scripts

To create a new script in a Script Editor Window, do one of the following:

bullet.gif    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.

bullet.gif    Click the down-arrow on the button on the main toolbar, and select [Script Manager]. In the Script Manager dialog, click [New].

Saving Scripts

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:

bullet.gif    Save to the same file using the File > Save command (Ctrl+S) or the button.

bullet.gif    Save to a different file using the File > Save As command.

Related Topics

Contents

Script Editor Window

Running Scripts shown in the User's Guide

Script Manager


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.