xml spy
Previous  Top  Next
Calling macros from XMLSpy

Once you have written your own macros (see also "How to write a macro"), you will want to execute them from XMLSpy. There are two ways to run macros.

Calling macros from the "Show macros..." dialog
To show this dialog select "Show macros..." from the "Tools" menu.

The dialog displays a list of all macros defined in the global scripting project and in the scripting project associated with the current project opened in XMLSpy.

Additionally, there is a "Run" button to call any selected macro. Before the macro is executed, the "Show macros..." dialog is closed.

scripting_showmacrosdlg  

The "Project" - list box lets you switch between the global scripting project and the project scripts.

Calling macros from the "Tools" menu
The XMLSpy API includes a function to add menu items with associated macros to the "Tools" menu.

To add a menu item call the XMLSpy API function AddMacroMenuItem().

To reset the "Tools" menu call ClearMacroMenu(). This removes all previously added menu items. These commands will generally be called from the "Autorun" macro of the global scripting project, or during the "On_OpenProject" event.

Example:

Application.AddMacroMenuItem("DeleteElements","Delete Elements Dialog");  

The first parameter is the name of the macro. If you run the macro and there is an open project with scripts associated to it, XMLSpy searches for the macro in the project scripts first. If there are no project scripts, or XMLSpy can't find the macro, it tries to find the macro in the global scripts.

The second parameter is the display text for the menu item.

Previous  Top  Next

⌐ 2002 Altova