Scripting Resources for DigitalMicrograph™


Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio | Private | Search


Example: Using a TagList

An example script which shows how to use the taglist structure to store lists of information.

version:20160709, v.10
D. R. G. Mitchell

Often one wishes to save lists of items. These might include filenames, numerical values, image processing parameters etc. For single numerical values, using an image as a storage array is very easy, but usually only as a temporary array while the script is running. To preserve information a more permanent method of storage is required. Also, only numerical values can be stored in an (array) image and so this will not work for string items or groups of mixed numerical/string information. Taggroups can be used, but in a taggroup each item must be given an identifying label. There are many cases where managing the naming of taggroup items, is not necessary and inconvenient. For such (unmanaged) lists, the taglist structure is the way to go. The order in which items are added is preserved, with each new item being added at the end of this list.

This example code shows how to record various bits of information (numerical and string) into a taglist and how to access the information therein. Taglist structures can be stored on images or in the persistent tags in the Global Info. Gatan use them extensively and you may have seen them in any tags you have explored on images or in the Global Info. Items in a list are labelled in numerical order bounded by square brackets : [0], [1] , [2]. . . etc. Information in such lists can be readily accessed as the first, nth or last using simple code shown here. This is very convenient as there are no labels on the list items to have to manage.

This example script requires an image be shown front-most. Each time the script is run, a new item is added to the 'Processing' taglist on the image, recording numerical and string information. This functionality could be used to record a sequence of image processing steps for example. Here the script will report the information in the last-but-one item added. If there is only one item in the list, then the last item is reported.

System Requirements
Should be compatible with all recent versions of DigitalMicrograph, but only tested on GMS 2.3 (Win 10).
Known Issues
Included Files
Main script file.
Source Code

See attached script