Admin Production ni-theme
Current Publication

Recording Macros

LabWindows/CVI

Tools»Source Code Macros

The Source Code Macros submenu contains menu items that you can use to create, execute, and manage macros. You can use a macro to repeat a series of actions, such as keystrokes and menu selections. For example, if all of your source files include the same header files or other common elements, you can record a macro that enters those elements and then save the macro for later use.

You can record two types of macros: temporary and permanent. A temporary macro is overwritten the next time you record another temporary macro. You can save permanent macros between sessions of LabWindows/CVI. You can then load saved macros into another instance of LabWindows/CVI. Saving and loading macros is helpful for sharing macros among multiple developers or storing macros in a source code control system.

The following menu items are available from the Source Code Macros submenu.

  • Record/Stop Macro—Records all of the actions that you perform from the time you select Record Macro until you select Stop Macro.
  • Record/Stop Temporary Macro—Records all of the actions that you perform from the time you select Record Temporary Macro until you select Stop Temporary Macro.
  • Play Temporary Macro—Executes the current temporary macro.
  • Pause/Continue—Temporarily stops recording a macro. Switching to a non-Source window pauses recording automatically.
  • Manage—Opens the Manage Macros dialog box.

The Source Code Macros submenu also lists permanent, saved macros. You can select a permanent macro from the menu to execute that macro.

Recording and Managing Macros

To record a macro, select Tools»Source Code Macros»Record or select Tools»Source Code Macros»Record Temporary Macro. While you are in record mode, the status bar at the bottom of the Source window displays Rec Macro. To stop recording temporarily, select Tools»Source Code Macros»Pause. To stop recording the macro, select Tools»Source Code Macros»Stop Macro or select Tools»Source Code Macros»Stop Temporary Macro, depending on the type of macro you are recording.

When you record a temporary macro, LabWindows/CVI stores it as the Temporary Macro. You can execute the temporary macro by selecting Play Temporary Macro or by pressing <Ctrl-Shift-V>.

When you finish recording a permanent macro, LabWindows/CVI displays the Manage Macros dialog box. Use the Manage Macros dialog box to rename a macro or assign a shortcut key to the macro. If you do not rename a permanent macro, the macro appears as New Macro n in the Macros list. Permanent macros are saved within LabWindows/CVI until you manually delete them.

You also can save macros to a .ini file. Click the Save button to specify a filename for the .ini file. To load saved macros, click the Load button.

To save a temporary macro, right-click the Temporary Macro in the Macros list of the Manage Macros dialog box and select Rename. Renaming the temporary macro creates a copy of that macro with the name you specify. You must rename a temporary macro to save it.

The following table lists the actions that you can record in a macro.

Source Window Menu Selections
Edit Menu Edit»Balance
Edit»Copy
Edit»Cut
Edit»Declare Parameter Variable
Edit»Delete
Edit»Find
Edit»Next File
Edit»Paste
Edit»Quick Search
Edit»Redo
Edit»Replace
Edit»Select All
Edit»Toggle Exclusion
Edit»Undo
View Menu View»Line
View»Next Tag
View»Previous Tag
View»Toggle Tag
Build Menu Build»Build Errors in Next File
Build»Next Error/Item
Build»Previous Error/Item
Source Window Context Menu Copy Current Line
Cut Current Line
Paste
Toggle Exclusion
Error Window Context Menu Copy All Items
Save to File
Keypress Actions
Key <Shift-Tab>
<Backspace>
<Delete>
<Enter>
Generic ASCII keys
<Ctrl-Shift-Backspace>
<Tab>
Source Window Miscellaneous Actions
Action Change text selection mode
Cut line to clipboard
Delete to end of line
Delete word
Find next
Find previous
Insert line above (<Enter-Shift>)
Insert line below (<Enter-Ctrl>)
Overwrite
Remove selection (<Esc>)
Replace and find next
Replace selection
Reverse quick search
Source code completion
Switch Source windows
Switch subwindows
Use selection as find string
Use selection as replace string
Cursor Movement
Action Move up one line
Move down one line
Move left one column
Move left one word
Move right one column
Move right one word
Move to beginning of line
Move to end of line
Move up one screen
Move down one screen
Move to top of window
Move to bottom of window
Move to top of file
Move to bottom of file
Scroll up one line
Scroll down one line

You also can use the shortcut keys of any of the actions listed in the table when you record a macro.

If you undo an action while you are recording, the undo becomes a part of the macro. When you execute the macro, each step is added to the undo stack. You can undo individual steps of the macro.