Using text substitution in the DMS file
You can use text substitution to replace text in a DMS file with your own text when you run the file. This is useful, for example, when you want to reuse DMS files in projects that have different data sources. Instead of manually changing the data source section, you can define a text substitution statement that will automatically insert the correct values when the DMS file is run.
Syntax
#define Search Replace
Parts
Search
Text that is to be replaced by Replace.
Replace
The text to replace Search.
Notes
▪You can include more than one #define statement in a DMS file. You must insert the statement before the appearance of the text that you want to replace and you must not use a line-continuation character in the #define statement. The search is case sensitive.
▪You can replace text in an
Include file by inserting a #define statement in your DMS file before the #include statement. For an example of replacing text in an Include file in this way, see
Using include files in the DMS file.
▪To restrict the range of a text substitution, insert an #undef statement in your DMS file at the point where you want the text substitution to stop. The following example shows how to restrict the range of a text substitution to the contents of an Include file:
#define textvar address
#include ".\Include\Include2.dms"
#undef textvar
▪When debugging DMS files that use text substitution, you may find it useful to use the DMS Runner
/a: option to save the DMS file after the text substitution has been implemented. See
DMS Runner.
Example 1
This example is based on the simple example described in
Example of a DMS file. However, a #define statement has been inserted at the beginning to change the names of the output files.
#define simple "TextSubstitution"
InputDataSource(myInputDataSource, "My input data source")
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location=C:\Program Files\UNICOM\Intelligence\<version>\DDL\Data\Data Collection File\museum.ddf; _
Initial Catalog=C:\Program Files\UNICOM\Intelligence\<version>\DDL\Data\Data Collection File\museum.mdd"
End InputDataSource
OutputDataSource(myOutputDataSource, "My output data source")
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrSavDsc; _
Location=C:\Program Files\UNICOM\Intelligence\<version>\DDL\Output\" + simple + ".sav"
MetaDataOutputName = "C:\Program Files\UNICOM\Intelligence\<version>\DDL\Output\" + simple + ".mdd"
End OutputDataSource
Example 2
This example uses the MSExcelToDDF.dms sample file included with the DDL.
#define ADOInfoFile "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MSExcelToDDF.adoinfo" ' The output Data Collection Data and MDD files... #define OutputDDFFile "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MSExcelToDDF.ddf" #define OutputMDDFile "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MSExcelToDDF.mdd" InputDataSource(Input) ConnectionString = "Provider=mrOleDB.Provider.2; _ Data Source=mrADODsc; _ MR Init MDSC=mrADODsc; _ Initial Catalog=" + ADOInfoFile SelectQuery = "SELECT * FROM vdata" End InputDatasource OutputDataSource(Output) ConnectionString = "Provider=mrOleDB.Provider.2; _ Data Source=mrDataFileDsc; _ Location=" + OutputDDFFile MetaDataOutputName = OutputMDDFile End OutputDataSource
See also