1. Automate DIAdem with the Script Recorder
Using the recording mode is the easiest way to create a script. DIAdem records the commands for each interactive step you execute. You can edit, test, and extend the recorded script. To record a script, click the Enable Recording Mode button ( ) on the toolbar. In the recording mode, your actions are recorded in the script editor. Common actions are loading data, executing calculations, populating a report template with data and exporting the report to share with colleagues. After you have finished your routine you wish to automate, you end the recording by clicking the Disable Recording Mode button (). Below is a video about using the Script Recorder.
2. Working with Scripts
VBScript is full scripting language developed by Microsoft. VBScript can handle commonly used programming constructs such as control structures, procedures, variables, etc. The script will be color coded to help distinguish between comments, commands and variables.
DIAdem had many features to help as you develop your script. You can use functions such as CodeCompletion, bookmarks, restoring, and find and replace, to make script editing easier. If you enter the name of an object and complete the entry with a dot, the script editor offers the properties, and methods that are available for this object as seen in the figure below. As of the DIAdem 2012 all the panels are object-oriented and the methods and properties are accessible this way.
3. Helpful Toolbar Button
|Start Script From File|| Expand Groups
| Enable Recording Mode
Disable Recording Mode
| Create User Dialog
| Find and Replace
Go To Line
| Bookmarks On/Off
*Debugging tools are not included with DIAdem install. You must install the Microsoft Windows Script Debugger to activate the debugging tools. See Debugging Scripts section for more details.
If you finish typing a command and open a parenthesis or position the cursor on a command, variable, or property of an object, the SmartInfo displays the parameters of the command. Click Display Help on This Subject… in the SmartInfo to call the detailed help which goes into full detail about the parameter inputs and return values.
4. Set a Shortcut for Commonly Used Scripts
After completing a script that will be used often, you can save even more time by setting up a shortcut key. You can do this on any panel by selecting the DIAdem script icon from the group bar. Here are twelve areas where you can assign scripts to a shortcut key. Right-click on the shortcut key you want and select Predefined Setting and navigate to the completed script. To activate the script while DIAdem is open and the active window press the Shift Key followed by the function key you assign your script to.
5. Debugging Scripts
DIAdem has integrated debugging tools that allow you to step through your program and catch syntax errors. However, to utilize this functionality, you must first install the Microsoft Windows Script Debugger. If the Microsoft Script Debugger is not installed, the debugging icons on the toolbar will be grayed out. To download the necessary software, go to the Microsoft Download Page and search for Microsoft Script Debugger.
One caveat of the integrated DIAdem debugging tools is that you cannot debug user dialog boxes and DataPlugins. However, you can debug user dialog boxes and DataPlugins with the Microsoft Script Editor by following the steps outlined in this tutorial: Using the Microsoft Script Editor to Debug DIAdem User Dialog Boxes (SUD) and DIAdem DataPlugins.
6. Scriptable User Dialog Boxes
In some instances you want the end user to interact with DIAdem, to enter certain parameters that may change on each run. To use scriptable user dialog boxes (SUD) you must have DIAdem Advanced or Professional. The SUD utilizes controls such as buttons, entry fields, selection lists or graphics. These controls have unlimited uses which can include loading files, requesting entries, configuring your analysis function(s), etc.
To get started in programming a scriptable user dialog box you can select the Create User Dialog Box toolbar button (). This will bring up the Dialog Editor where you can customize the look and functionality of the dialog box.
1 – Control Toolbar. Select how you want the user to interact with the dialog box.
2 – Dialog Box. Customize the design of your dialog box
3 – Toolbar. Preview and test the SUD in DIAdem and format the dialog box.
4 – Control Properties Configuration Box. Set up events, variables, and customize look of control
Once you have your dialog box you can add call the SUD from the script editor. For tutorials and additional information on how to accomplish this, look at the DIAdem help for Creating User Dialog Boxes.