Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

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

 

Example: Traversing Persistent Tag Group
Function
Shows how to navigate through the persistent tag group to locate the tag group names, where the taggroup name is known
Version
version:20091003, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments
The persistent tag group contains the information displayed in tags window (File/Global Info). This information is non-volatile, and will persist after the script has finished or DM has been shut down. This makes it the ideal way to save information such as preferences and settings. Furthermore, it is easy to save tag groups in a settings file, to subsequently update the persistent tags, or for transfer to another PC - for example as a settings file to load preferences with a script. See the example script Taggroup Creation-Adding-Saving to Global Info.
System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
-
Supported
Yes
Included Files
Main script file.
Source Code

// Example to show how to access the titles of a series of existing tags

// In this case the tags are listed as

// DiffTools

// Camera Lengths

// 1.2cm, value

// 1.5cm, value etc

 

// D. R. G. Mitchell, Oct 2009

// version:20091003, v1.0

// adminnospam@dmscripting.com (remove the nospam to make this email address work)

 

// Get the persistent tag group

 

taggroup ptags=getpersistenttaggroup()

 

// Get the target taggroup

 

taggroup difftags

ptags.taggroupgettagastaggroup("DiffTools:Camera Lengths",difftags)

 

// Cound the number of tags within it

 

number tagcount=difftags.taggroupcounttags()

 

number i

string tagstring

 

// Access the titles of the tags

for(i=0;i<tagcount; i++)

{

getnthpersistentnotetitle("DiffTools:Camera Lengths",i,tagstring)

result("\n"+tagstring)

}

 

// Access the values stored in each tag

 

number tagval

 

for(i=0;i<tagcount;i++)

{

getnthpersistentnotetitle("DiffTools:Camera Lengths",i,tagstring)

 

string fulltagpath="DiffTools:Camera Lengths:"+tagstring

 

getpersistentnumbernote(fulltagpath,tagval)

result("\n"+tagstring+" : "+tagval)

 

}