DIAdem offers high levels of customisation through VBS scripts. You can just run these from file but sometimes you want to integrate these into the environment, either because you use them a lot or you want colleagues who aren't as script savvy. This example demonstrates the API for doing this and also using an XML file to define these to create a scalable script for this.
DIAdem allows you to edit the menus through the MenuItem functions. The key fuction is MenuItemInsert. This allows you to enter one of three items in a particular location. This can either be:
The location is then defined with an index value, with a . separating each layer e.g. 1.1 is the normal location for File>>New
Normally you will want the script that runs this to be your start up script so that it is populated on starting DIAdem.
As you add multiple sets of scripts your startup script to add these to the menu can become a mess! Loading a configuration from file is a scalable of keeping a simple script but easy reconfiguration.
XML was chosen for this example as it is a heirarchy based file structure which maps nicely to the menu setup. It is also easy to manipulate programmatically or by hand.
To deal with this file format we use the Microsoft XML parser. This is made available through ActiveX which we can access through the CreateObject function:
Set xDoc = CreateObject("MSXML2.DOMDocument.3.0")
Then we can load the structure, one layer at a time as a collection of the different nodes and each node is an object. The best place for documentation of this tends to be on MSDN.
For this script the XML file contains several different tags.
Attached is an example file which uses msgbox instead of script start to allow you to try it out. Put this and the script in the same folder and run the script. You will then see the menu items added to DIAdem. For more information on MenuItemInsert and similar functions see the DIAdem help or this is covered in the DIAdem Advanced course.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.