Scripting Resources for DigitalMicrograph™

Banner Image

Dave Mitchell's DigitalMicrograph™ Scripting Website

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

Tutorial: Scripting differences between GMS 2 and earlier versions


Scripting Topics:

Results Window

Scripting Tag Group

Directory Structure and File Locations

(note: this list will evolve as differences are found)


Results Window

In GMS 1.8 and earlier, the Results window was a scriptable object and could be accessed by commands such as getresultswindow(). In GMS 2 the Results window was changed and was no longer accessible. The following commands were removed:



Scripts which attempt to use these commands in GMS 2 will generate errors. The results window morphed into the 'Output' window. This has three tabbed panels: Results, Notes and Debug. Pre GMS 2 scripts which output data to the Results window, will output that data to the Results tabs of the Output window in GMS 2. Prvevioulsy only strings could be sent to the Results window. In GMS 2 numbers can be sent also. However, to maintain backward compatibility it is probably best to send only strings. The new command set for accessing the three tabs of the Output window are as follows:

"void Result(double, string format)"

Output the real number with the printf-style format to the results window.

"void Result( dm_string )"

Output the string to the results window.

"void Result(double)"

Output the real number to the results window.

"void Result(complex)"

Output the complex number to the results window.

"void Result(RGB)"

Output the RGB number to the results window.

"void Notes( dm_string )"

Output the string to the notes window.

"void Debug( dm_string )"

Output the string to the debug window.

"void ClearResults( )"

Erases all text from the results window.

"void ClearNotes( )"

Erases all text from the notes window.

"void ClearDebug( )"

Erases all text from the debug window.

"void OpenOutputWindow( )"

Opens the output window.

Back to top


Scripting Tag Group

The scripting tag group contains the attributes which control the appearance of the script window - font, font size, numbering on/off etc. This tag group used to be located within the Global info. However, in GMS 2 Gatan have moved it up one level so now it appears at the same level as the Global Info. This is so that configurations are user specific.

Screen shot of the scripting tag group

I have accessed this tag group when using a script window for outputting a table of data. Typically when writing scripts it is very useful to have line numbering turned on. However, when outputting data the numbers are not required. In GMS 1.8 I would typically access the scripting tag group, turn off the 'Show Line Numbers' option, create a script window, output the data, then turn the line numbers back on. In GMS 2 the relocation of this tag group means that scripts which look for the scripting tag group do not find it. They do not generate errors, but nor do they turn off line numbering. Therefore, a script using this technique will work correctly in 1.8, but may produce a data table with line numbers in GMS 2 (if the 'Show Line Numbers' option was checked). The Scripting tag group in GMS 2 can be accessed with the following command:


However, this command does not exist in GMS 1.8, and any scripts which used it would not be backwardly compatible. For this reason, I have avoided it. If users in GMS 2 get line numbers in data tables, they can simply turn off the 'Show line numbers' option manually.

Back to top


Directory Structure and File Locations

In GMS 1.8 the main directory structure was /Program Files/Gatan/DigitalMicrograph/DigitalMicrograph.exe. In GMS 2 this has changed to /Program Files/Gatan/DigitalMicrograph.exe ie the DigitalMicrograph folder has been dispensed with. Of much greater significance is the fact that in GMS 2. files such as licenses and plugins are no longer installed in the main program folder, but are in the user folders. The licenses appear in: C:\Documents and Settings\All Users\Application Data\Gatan\Licenses. What initially perplexed me was the location of script packages I was creating. In GMS1.8 these would appear in the plugins folder inside the DigitalMicrograph folder. In GMS 2 these are relocated to a user specific directory, again with a view that anything installed by one user does not automatically affect everyone else. The directory for user created plugins (and also preferences) is: C:\Documents and Settings\David\Local Settings\Application Data\Gatan\Plugins - for 'David' simply substitute your user name.

If you are creating a plugin and want it to be universally accessible to all users of the system, you must move your plugin from the user specific directory, to that in the main Gatan directory ie: C:\Program Files\Gatan\Plugins. I have found that script packages created in GMS 1.8 are fully compatible with GMS 2. However, I did find that a package created in GMS 2 would not load in 1.8. I need to repeat this to see if it is consistent, but in the mean time, if you have the option of creating your package in either version - do so in 1.8.

Back to top