LabelTypes, contexts, and languages collections
Displaying a numeric variable in UNICOM Intelligence Interviewer - Paper describes the Labels object and how it makes use of the label type, user context, and language. This topic describes more about the
LabelTypes,
Contexts and
Languages collections. The first mrScriptBasic example shows how to view the default members of these collections of an MDM Document.
Dim MyDocument, MyLabelType, MyContext, MyLanguage
Set MyDocument = CreateObject("MDM.Document")
MyDocument.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\My New Numeric Variable.mdd", , _
MDMLib.openConstants.oREAD)For Each MyLabelType In
MyDocument.LabelTypes Debug.Log(MyLabelType.Name)
Next
For Each MyContext In MyDocument.Contexts
Debug.Log(MyContext.Name)
Next
For Each MyLanguage In MyDocument.Languages
Debug.Log(MyLanguage.Name + ": " + MyLanguage.LongName)
Next
MyDocument.Close()
A similar example in VB.NET is:
Private Sub Default_LabelTypes_Contexts_Languages()
Dim MyDocument As MDMLib.Document
' Note that the member objects of both the LabelTypes and Contexts
' collections are of type Context...
Dim MyLabelType As MDMLib.Context
Dim MyContext As MDMLib.Context
Dim MyLanguage As MDMLib.Language
MyDocument = New MDMLib.Document
MyDocument.Open(" [INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Output\My New Numeric Variable.mdd")
For Each MyLabelType In MyDocument.LabelTypes
Debug.Write(vbCrLf & MyLabelType.Name)
Next
For Each MyContext In MyDocument.Contexts
Debug.Write(vbCrLf & MyContext.Name)
Next
For Each MyLanguage In MyDocument.Languages
Debug.Write(vbCrLf & MyLanguage.Name & ": " & MyLanguage.LongName)
Next
MyDocument.Close()
End Sub
Running this code tells you that the default member of the LabelTypes collection is Label and the default members of the Contexts collection are Question and Analysis. It also tells you the default member of the Languages collection. However, if you do not specify the default language when you create the Document, the default member of this collection depends upon the locale (location) selected in Regional Options in Control Panel when the .mdd was created. For example, if your locale is defined as English United States, the default member of the Languages collection is ENU (English United States). The example displays the LongName property of the language. Language long names are not case sensitive.
When you save an MDM Document, the Base property is saved but the Current property is not. When an MDM Document is loaded, the Current property is automatically set to the Base property. For example, if you add the following lines of code to the end of the script:
Debug.Log("Base Language : " + MyDocument.Languages.Base)
Debug.Log("Current Language : " + MyDocument.Languages.Current)
A similar example in VB.NET is:
Debug.Write(vbCrLf & "Base Language : " & MyDocument.Languages.Base)
Debug.Write(vbCrLf & "Current Language : " & MyDocument.Languages.Current)
You can see that the Base and Current properties of the Languages collections are both set to the default language for your locale. When you set the Base and then save the MDM Document, you control what the value of the Current property will be the next time the Document is loaded. This is useful because in the line from the previous example MyVariable.Labels["Label"].Text["Question"]["ENU"] = "How much do you spend on our products per year?" the items in brackets (“Label”, “Question”, and “ENU”) are all optional parameters. If you do not explicitly specify these parameters, the MDM automatically supplies the value of the Current property for the LabelTypes, Contexts, and Languages collections respectively. If you decide not to supply these parameters, you can either explicitly set the Current property for these collections, or effectively use the Base property.
Next topic
See also