Altova XMLSpy 2024 Enterprise Edition

Macros are scripts that contain JScript (or VBScript, depending on your project's language) statements, such as variable declarations and functions.

 

If your projects should use macros, you can add them as follows: right-click inside the Project pane, select Add Macro from the context menu, and then enter the macro's code in the main form. The code of a macro could be as simple as an alert, for example:

 

alert("Hello, I'm a macro!");

 

More advanced macros can contain variables and local functions. Macros can also contain code that invokes forms from the project. The listing below illustrates an example of a macro that shows a form. It is assumed that this form has already been created in the "Forms" folder and has the name "SampleForm", see also Forms.

 

// display a form
ShowForm( "SampleForm" );

 

In the code listing above, ShowForm is a command built into Scripting Editor. For reference to other similar commands that you can use to work with forms and .NET objects, see the Built-in Commands.

 

You can add multiple macros to the same project, and you can designate any macro as "auto-macro". When a macro is designated as "auto-macro", it runs automatically when XMLSpy starts. To designate a macro as auto-macro, right-click it, and select Set as Auto-Macro from the context menu.

 

Only one macro can be run at a time. After a macro (or event) is executed, the script is closed and global variables lose their values.

 

To run a macro directly in Script Editor, click Run Macro scr_ic_run_macro. To debug a macro using the Visual Studio debugger, click Debug Macro scr_ic_debug_macro. For information about enabling and running macros in XMLSpy, see Enabling Scripts and Macros.

 

© 2017-2023 Altova GmbH