Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with the Metadata Model: Tutorial > Name handling and object look up
 
Name handling and object look up
When you add an object to the Elements, Types, Fields, or HelperFields collections, the MDM checks that the name of the object you are adding is valid and unique within the collection. In addition, all objects that can be added to these collections have a FullName property, which you can use to look up the object. For example, the MDM generates a variable's full name by combining its name with the names of its parent objects and you can use the full name to look up the variable. This is particularly useful when the variable you want to look up is contained in a nested collection.
To illustrate this, look at the Respondent.Serial system variable, which is contained in a Class object called Respondent. You can access this variable through the Document.Fields collection by drilling down through the collections, as demonstrated in this mrScriptBasic example:
Dim MyDocument, MyVariable

Set MyDocument = CreateObject("MDM.Document")

MyDocument.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd", , _
MDMLib.openConstants.oREAD)

Set MyVariable = MyDocument.Fields["Respondent"].Fields["Serial"]
However, it is easier to access the variable directly through the top-level collection by using the variable’s full name, like this:
Set MyVariable = MyDocument.Fields["Respondent.Serial"]
You can use a similar method to access the variables in the HelperFields collections. For example, the Respondent.Serial system variable has a helper field called Respondent.Serial.SourceFile. You can access this variable through Document.Fields, like this:
Set MyVariable = MyDocument.Fields["Respondent"].Fields["Serial"].HelperFields["SourceFile"]
But it is easier to access the variable using its full name:
Set MyVariable = MyDocument.Fields["Respondent.Serial.SourceFile"]
You can also access variables inside a grid or array using the variable’s full name. For example:
Set MyVariable = MyDocument.Fields["Ratingzz.rating1"]
Set MyVariable = MyDocument.Fields["Ratingzz[..].rating1"]
Both the Class and Compound objects have a Types collection, which is used to list template objects. You can look up a template object in the Document.Fields collection using the object’s full name, provided the template object is listed in a Compound or Class object’s Types collection. However, you must prefix the template object’s name with @Types. For example, to access a shared list called Choice in a Compound object called Colors, use:
Set MyVariable = MyDocument.Fields["Colors.@Types.Choice"]
You cannot access the objects in the Document.Types collection in this way.
Next topic
Understanding the Variable and Element classes
See also
Working with the Metadata Model: Tutorial
Creating and saving a variable