Using Klocwork Architect scripts
You can use the Klocwork Architect scripting interface to write scripts that work with Architect custom diagrams and models. Scripts can be useful in automating repetitive tasks or performing a repeatable set of actions on a number of projects. You may also wish to use these commands to modify scripts created from actual Architect editing sessions. The commands are written in standard tool command language (TCL) version 8.0 (a Sun Microsystems scripting language), with some Klocwork enhancements.
This page shows you how to create and work with scripts. For a complete list of Architect scripting commands, see Klocwork Architect scripting commands.
Running a script
You can run scripts that perform editing operations in Klocwork Architect. Such scripts, created using the Architect scripting interface, can save you time by automating repetitive tasks or creating custom diagrams or models that allow you to look at particular aspects of your system.
To run a script on model (the instructions are comparable for custom diagrams):
- Open a Graphic view of the model for which you want to review your editing operations.
- Note: If your script contains the saveModel command at the beginning, it doesn’t matter which model you open, since Architect will save a new model. If your script does not contain the saveModel command, or the saveModel command appears after editing operations in the script, you must open a Graphic view of a model you own before executing the script.
- Click Scripts > Execute Script.
- The Execute Script from... dialog appears.
- Navigate to the directory in which you saved your script and locate the file.
- Click Execute.
- In the Graphic view, you see all of the scripted operations that you performed on the original model. If your script contains the saveModel <name> command, the model is saved with the name you specified.
You can create menu items for your own scripts to make it easier to run them several times in succession.
After you execute this procedure, your script stays attached to the Scripts menu even if you switch to another project build or Klocwork Server, close the current Graphic view or exit Architect. This allows you to easily run generic scripts on multiple custom diagrams or multiple models in multiple project analyses. If your script is dependent on a particular build, custom diagram or model, you may want to establish a naming convention to help you remember what the script applies to.
To attach a script to the Scripts menu, open a Graphic view of a custom diagram or model and click Scripts > Attach Script..., and follow the prompts.