|
IDL Interface Guide: Creating Development Environment Macros |
|
Below are two examples that illustrate how a macro is created in IDL. The first example below is a UNIX-only example; the second example will work on either Microsoft Windows or UNIX.
On UNIX platforms, you can create a macro to open a file that is currently open in the IDL Editor in another editor, such as emacs or vi. Use the following procedure to create the macro:
Edit menu to bring up the Edit Macros dialog box. You can use this dialog to create, edit, or remove macros.
emacs.
emacs.
SPAWN, 'emacs +%L %P &'
emacs in the Label field, a new "emacs" macro is added to the Macros list.
SPAWN, 'xterm -e vi +%L %P &'
| Note The IDLDE always checks to determine whether the current file has been externally modified before using it. If a file was modified with an external editor, IDLDE notifies you, and asks you to reload the file before using it. You can also use the Revert to Saved option from the File menu to reload the file. |
The following macro will select and change your current working directory. The steps below describe the fields of the Macros dialog on a Microsoft Windows system, but the macro will work equally well on a UNIX system.
First we will create a .pro file in IDL which will display a platform-specific directory-selection dialog.
New
Editor.
PRO cd_test dir = DIALOG_PICKFILE(/DIRECTORY) IF (dir) THEN BEGIN PRINT, 'Changing to: ', dir CD, dir ENDIF END
cd_test.pro in a directory included in IDL's path. (The file must be in IDL's path so that IDL will find it automatically when the command cd_test is executed by the macro we will create.)
Edit menu to bring up the Edit Macros dialog box.
To use the new macro, select "Change Directories" from the Macros menu.
IDL Online Help (March 06, 2007)