Working with Macros
Select Edit > Macros to open the Macros sub-menu. Use the options in this menu to create and manage macros for use in Editor windows. Alternatively, use the toolbar buttons in the Macros toolbar to access these functions. NetLinx Studio Macros Files use the file extension *.NSM. The options in the Macros sub-menu/toolbar are as follows:
Macros Sub-Menu/Toolbar Options | |
---|---|
Record | Click to start recording a new macro. This action open the New Macro dialog, in which you must provide a name for the new NetLinx Macro File (*.NSM) - required, and a file description (optional). |
Pause Recording | Click to pause a macro recording in progress. Click Pause Recording again to resume recording the macro. |
Cancel Recording | Click to cancel the current macro recording. |
Stop Recording | Click to stop recording the current macro. |
Run <macro name> | Click to play the currently active macro. If you have just finished recording a macro, that macro will be run. Otherwise, use the Load Macros and Select Macro options to load and select a different macro, then select Run. |
Load Macros | Click to load one or more macro files. This option invokes the Open dialog to locate and select the macro file(s) to be loaded. Once one or more macro files are loaded, they can be selected to run via the Select Macro option. |
Select Macro | Click to open the Select a Macro dialog. Use this dialog to select a macro to run. |
Edit Macros | Click to open the Edit Macros dialog. Use the options in this dialog to delete existing macros. |
Save Macros | Click to save all currently loaded macro files, via the Save As dialog. |
Recording a Macro
- Select Edit > Macros to access the Macros sub-menu, and select Record (alternatively, click the Start a New Recording
toolbar button in the Macros toolbar). This opens the New Macro dialog (FIG. 192).
Macros toolbar options
FIG. 192 New Macro dialog
- Enter a Name and (optionally) a Description for the new macro.
- Click OK to close the dialog and begin recording. All keystrokes that are used within the open Editor windows will be recorded as part of this macro.
- To Pause the recording, click the Pause Recording toolbar button (or select Edit > Macros > Pause Recording).
- To Cancel the recording, click the Cancel Recording toolbar button (or select Edit > Macros > Cancel Recording).
- To Stop the recording, click the Stop Recording toolbar button (or select Edit > Macros > Stop Recording).
- Once the macro has been recorded, it can be Played. When a macro is played (via the Play Current Macro toolbar button or Edit > Macros > Play Current Recording), all keystrokes recorded in the currently loaded macro are repeated at the cursor position in the active Source Code File.
NOTE: Unless you have selected a different macro (via the Load Macros toolbar button, or Edit > Macros > Load Macros), the last recorded macro is the current macro and therefore will be played when Play Current Macro is selected.
Saving NetLinx Studio Macro Files (*NSM)
- Select Edit > Macros to access the Macros sub-menu, and select Save Macros. .
- In the Save As dialog, specify a target directory and filename for this macro file and click Save.
Running a Macro
Unless you have selected a different macro (via Edit > Macros > Load Macros), the last recorded macro is the current macro and therefore will be played when Play Current Macro is selected.
- Place the cursor in an Editor window, at the point in the code that you want to play the current macro.
- Select Edit > Macros > Run ’Current Macro’.
- To play a different macro, you'll need to first load a different macro, via the Edit > Load Macros option.
- If several macros have been loaded, select the macro you want to run via the Select a Macro dialog. Select Edit > Macros > Select Macros to access this dialog (FIG. 193):
FIG. 193 Select a Macro dialog
Selecting Macros
If more than one macro file has been loaded in the current session, you can select which particular macro to run via the Select a Macro dialog:
- Select Edit > Macros > Select Macro to open the Select a Macro dialog.
- All currently loaded macros are listed in the Available Macros list.
- Select the macro that you want to run, and click Select. This closes the Select a Macro dialog, and the selected macro is now the current macro.
- Click Edit > Macros > Run '<macrof ilename>', to run the selected macro.