Document Information
Sometimes it is convenient to know about an MDM Document's versions, user contexts, and languages without having to load the entire Document. An example of this is in the UNICOM Intelligence Interviewer - Paper Open Questionnaire dialog where the user can view the versions and languages in an MDM Document by simply clicking on the file name inside the dialog. This dialog would not be usable if the entire Document had to be loaded each time. UNICOM Intelligence Interviewer - Paper takes advantage of an MDM facility known as DocumentInfo, or Document Information. Here is an mrScriptBasic example:
Dim MyDocumentInfo
Dim MyVersions, MyContexts, MyLanguages
Dim MyVersion, MyContext, MyLanguage
Dim MyVersionNo
' Create a DocumentInfo object
Set MyDocumentInfo = CreateObject("MDM.DocumentInfo")
' Using the DocumentInfo object, open the
' Short Drinks sample Document file
MyDocumentInfo.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd")
' List all the versions in the Document
Set MyVersions = MyDocumentInfo.Versions[""]
For Each MyVersion In MyVersions
Debug.Log(MyVersion.FullName)
Next
MyVersionNo = "6"
' List all the user contexts in version 6 of the Document
Set MyContexts = MyDocumentInfo.Contexts[""][MyVersionNo]
For Each MyContext in MyContexts
Debug.Log(MyContext.Name)
Next
' List all the languages in version 6 of the Document
Set MyLanguages = MyDocumentInfo.Languages[""][MyVersionNo]
For Each MyLanguage in MyLanguages
Debug.Log(MyLanguage.Name)
Next
A similar example in VB.NET is:
Private Sub Document_Information()
Dim MyDocumentInfo As MDMLib.DocumentInfo
Dim MyVersions As MDMLib.Versions
Dim MyContexts As MDMLib.Contexts
Dim MyLanguages As MDMLib.Languages
Dim MyVersion As MDMLib.Version
Dim MyContext As MDMLib.Context
Dim MyLanguage As MDMLib.Language
Dim MyVersionNo As String
' Create a DocumentInfo object
MyDocumentInfo = New MDMLib.DocumentInfo
' Using the DocumentInfo object, open the
' Short Drinks sample Document file
MyDocumentInfo.Open(" [INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd")
' List all the versions in the Document
MyVersions = MyDocumentInfo.Versions("")
For Each MyVersion In MyVersions
Debug.Write(vbCrLf & MyVersion.FullName)
Next
MyVersionNo = "6"
' List all the user contexts in version 6 of the Document
MyContexts = MyDocumentInfo.Contexts("", MyVersionNo)
For Each MyContext In MyContexts
Debug.Write(vbCrLf & MyContext.Name)
Next
' List all the languages in version 6 of the Document
MyLanguages = MyDocumentInfo.Languages("", MyVersionNo)
For Each MyLanguage In MyLanguages
Debug.Write(vbCrLf & MyLanguage.Name)
Next
End Sub
This example displays all of the versions associated with an .
mdd file and all of the user contexts and languages associated with a given version of the file. Note that this example shows using the DocumentInfo.Open method (see also
IDocumentInfo_Open in the MDM Object Model Reference) to open a file before accessing the other properties on the object. This makes the access faster.
Requirements
Optional: Microsoft Visual Basic .NET 2003
Next topic
See also