Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Opening an MDM document in a script
 
Opening an MDM document in a script
Functions that are passed categorical values that contain category names or a category expression must be able to reference an open MDM document, which can be in the form of an MDM document stored in a .mdd file or an MDM document generated from proprietary metadata by a read-enabled MDSC. If an open MDM document is not available, the categorical value passed to the function must consist only of category numbers, otherwise an error will occur.
In a mrScriptBasic script, you typically specify an open MDM document in one of two ways:
By using the CreateObject function to create and return a reference to an MDM document object, and then using the object's Open method to open an MDM document stored in a .mdd file. For example, the following mrScriptBasic example opens the museum.mdd sample file for read-only access. The document is then accessible to functions by using the variable MyDocument. [INSTALL_FOLDER] is the directory where you installed UNICOM Intelligence, such as C:\Program Files:
Dim MyDocument
Set MyDocument = CreateObject("MDM.Document")
MyDocument.Open("[INSTALL_FOLDER]\UNICOM\Intelligence\<version>\DDL\Data\Data Collection File\museum.mdd", , _
MDMLib.openConstants.oREAD)
For a fuller example of this method, see Rot.
By using the /m: option of the mrScript Command Line Runner to specify an MDM document to be opened for read-only access. The document is then accessible to functions via an intrinsic variable called MDM.
In a Data Management Script (DMS) file, the MDM document specified in the InputDataSource section is automatically available as an open document in the OnJobStart, OnAfterMetaDataTransformation, OnNextCase, OnBadCase, and OnJobEnd event sections of the script.
See also
UNICOM Intelligence function library