Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with the Metadata Model: Tutorial > Adding to the LabelTypes, Contexts, and Languages collections
 
Adding to the LabelTypes, Contexts, and Languages collections
Adding to the LabelTypes and Contexts collections is straightforward. For example, if your application requires a LabelType of LongQuestionText, add this line:
MyDocument.LabelTypes.Add("LongQuestionText")
You can use the same method for the Contexts collection (for example, MyDocument.Contexts.Add("MyNewContext")). However, the Languages collections only allows you to add languages that the MDM understands. To make this easier the MDM provides another collection, the LanguageDefinitions collection, which lists the supported languages. This code iterates through all of the languages supported by the MDM:
Dim LanguageDefinitions, i

Set LanguageDefinitions = CreateObject("MDM.LanguageDefinitions")

For i = 0 To LanguageDefinitions.Count - 1
Debug.Log(LanguageDefinitions[i] + " " _
+ LanguageDefinitions[i][MDMLib.LanguageConstants.langSLANGUAGE])
Next
A similar example in VB.NET is:
Private Sub MDM_Languages()
Dim LanguageDefinitions As MDMLib.LanguageDefinitions
Dim i As Integer

LanguageDefinitions = New MDMLib.LanguageDefinitions

For i = 0 To LanguageDefinitions.Count - 1
Debug.Write(vbCrLf & LanguageDefinitions(i) & " " _
& LanguageDefinitions(i, MDMLib.LanguageConstants.langSLANGUAGE))
Next i
End Sub
The line inside the For...Next statement prints both the short and the long version of the language on the same line. When adding to the Languages collection you can use either version. For example, use MyDocument.Languages.Add("PTB") or MyDocument.Languages.Add("Portuguese (Brazil)") to add Portuguese (Brazil) to the Languages collection.
Requirements
See Requirements.
Next topic
Creating text and categorical variables
See also
Working with the Metadata Model: Tutorial
Creating and saving a variable