Developer Documentation Library > Data Model > Available DSCs > mrScript MDSC (mrRoutingScript MDSC)
 
mrScript MDSC (mrRoutingScript MDSC)
The mrRoutingScript MDSC (mrRoutingScriptDsc.dll) reads an MDM document (.mdd) file and processes the collection of RoutingItem objects to create a routing script that can be used for interviewing in version 3.0 or later of UNICOM Intelligence Interviewer - Server Admin.
RoutingItem objects are created when you use the Build activity in UNICOM Intelligence Interviewer - Server Admin to create a questionnaire. A routing item is simply a reference to a question in the Fields collection of the MDM document. The order of the RoutingItem objects in the collection defines the order in which the questions will be asked in the interview.
An MDM document can also contain a collection of Script objects, which store an mrScriptBasic script as a string property. These objects are created by authoring tools such as UNICOM Intelligence Professional, in which you specify the routing by writing a script. Version 3.0 or later of UNICOM Intelligence Interviewer uses Script objects (and not RoutingItem objects) to determine the flow of the interview. Therefore, to allow questionnaires created in Build to run in version 3.0 or later of IBM SPSS Data Collection Interviewer Server, the mrRoutingScript MDSC is used to process the collection of RoutingItem objects and generate a Script object.
In order for the mrRoutingScript MDSC to successfully create a Script object, the MDM document must have one or more routing contexts for which collections of RoutingItem objects exist. By default, the mrRoutingScript MDSC processes the Paper routing context. Alternatively, you can specify another routing context to process by setting the RoutingContext property described later in this topic.
Elements of a generated routing script
The mrRoutingScript MDSC automatically adds a heading, an error handler, and some property settings for the Interview Object Model (IOM) to the top of the routing script. The error handler is automatically enabled when the interview is run in UNICOM Intelligence Interviewer and simplifies debugging for questionnaire designers using the Build activity. The error handler is not used when running the interview in UNICOM Intelligence Professional, as the scriptwriter can use UNICOM Intelligence Professional's debugging capabilities instead.
Example of the generated script
'--- Script header ---
' Interview script created by Routing Script MDSC (Unicode)
' mrRoutingScriptDsc 1.0.6.2353
' Date/time script generated: 2006-09-06 13:23

'--- End script header ---

'--- Error handler ---
If Not IOM.Info.IsDebug Then On Error Goto __DefaultErrHandler
Goto __StartOfScript

__DefaultErrHandler:
Dim __err_msg, __error
__err_msg = "Script error at line " + CText(Err.LineNumber) + ", " + Err.Description
IOM.Log(__err_msg, LogLevels.LOGLEVEL_ERROR)
If IOM.Info.IsTest Then
IOM.Banners.AddNew("__ScriptErrMsg" + CText(__error), __err_msg)
__error = __error + 1
End If
Resume Next

__StartOfScript:
'--- End error handler ---

IOM.LayoutTemplate = ""
IOM.MustAnswer = true
The mrRoutingScript MDSC then adds the appropriate script for each routing item after the line "IOM.MustAnswer = true".
Properties of mrRoutingScript MDSC
If you create an mrRoutingScript MDSC object to use in your own program or script, you can set the following properties for the object:
LabelAll
Type: Boolean
Set to true to generate labels for all routing items. By default, labels are generated only for items referenced by Goto's. For more information, see Questions and response-based Goto's.
LongGotos
Type: Boolean
Set to true to generate the long form of Goto's. By default, the short form is generated. For more information, see Questions and response-based Goto's.
RoutingClass
Type: String
The name of a Class objects in the MDM document whose collection of RoutingItem objects will be used as the basis for the script. By default, the collection of RoutingItem objects for the MDM document's Routing object is used.
RoutingContext
Type: String
The routing context to process. By default, the Paper routing context is processed.
SuppressHeader
Type: Boolean
Set to true if you do not want a heading to be added to the top of the routing script.
Example
The following mrScriptBasic example demonstrates how to set the LabelAll and SuppressHeader properties when using the mrRoutingScript MDSC to generate a routing script:
' IMPORTANT: Before running this script, you must register
' "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Code\DSCs\Test Tools\CDSCProperties.dll"

Dim MyProperties, MyProperty, mrRsDSC, MDM, MyRoutingScript

Set MDM = CreateObject("MDM.Document")

'Open the Museum sample metadata document...

MDM.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\museum.mdd", , 1)

Set MyProperties = CreateObject("CDSCProperties.Properties")
Set MyProperty = CreateObject("CDSCProperties.Property")

' Create the LabelAll property and add it to
' the properties collection...

With MyProperty
.strName = "LabelAll"
.Value = True
.cdPropType = 1
End With

MyProperties.Add(MyProperty)

' Create the SuppressHeader property and add it to
' the properties collection...

With MyProperty
.strName = "SuppressHeader"
.Value = True
.cdPropType = 1
End With

MyProperties.Add(MyProperty)

' Create a mrRoutingScript MDSC object...

Set mrRsDSC = CreateObject("mrRoutingScriptDsc.ConvToScript")

' Using the properties collection,
' generate a routing script from the
' "Paper" collection of routing items in
' the Museum metadata document...

MyRoutingScript = mrRsDSC.ConvertToData(MDM, 0, MyProperties)

' Display the routing script...

Debug.Log(MyRoutingScript)
See also
Questions and response-based Goto's
Other types of routing items
Custom properties on the routing object
Available DSCs