Example 2: A complete example
This topic shows the code from
Example 1: More than one response to a single response question as it would appear in a DMS file.
The InputDataSource section contains a select query, which specifies some variables by name. Each of these variables is available as a Question object in the OnNextCase Event section.
InputDataSource(Input)
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location=C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\museum.ddf; _
Initial Catalog=C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\museum.mdd"
SelectQuery = "SELECT Respondent.Serial, DataCleaning.Note, _
DataCleaning.Status, interest, age, gender, expect, time_spent _
FROM VDATA _
WHERE Respondent.Serial < 101"
End InputDataSource
Event(OnJobStart, "Do the set up")
Dim fso, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\Cleaning.txt", True, True)
dmgrGlobal.Add("mytextfile")
Set dmgrGlobal.mytextfile = txtfile
expect.Response.Default = {general_knowledge_and_education}
End Event
Event(OnNextCase, "Clean the data")
Dim strDetails
strDetails = CText(Respondent.Serial)
If interest.AnswerCount() > 1 Then
interest = {Not_answered}
End If
If gender.AnswerCount() > 1 Then dmgrJob.DropCurrentCase()
If time_spent.AnswerCount() > 1 Then
time_spent = time_spent.Response.ran(1)
End If
If age.AnswerCount() > 1 Then
DataCleaning.Note = DataCleaning.Note + " Age needs checking."
DataCleaning.Status = {NeedsReview}
strDetails = strDetails + " Age needs checking."
End If
If expect.AnswerCount() > 1 Then
expect.Validation.Validate(ValidateActions.vaAssignDefault)
End If
dmgrGlobal.mytextfile.WriteLine(strDetails)
End Event
Event(OnJobEnd, "Close the text file")
dmgrGlobal.mytextfile.Close()
End Event
OutputDataSource(Output, "The output data source")
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location=C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\Cleaning.ddf"
MetaDataOutputName = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\Cleaning.mdd"
End OutputDataSource
Note This example is provided as a sample DMS file (called
Cleaning.dms) that is installed with the UNICOM Intelligence Developer Documentation Library. For more information, see
Sample DMS files.
Requirements
UNICOM Intelligence Professional
See also