#define and #undef
Use the #define directive to substitute text in a source file. Then use the #undef directive to limit the range of the substitution.
The
#define directive can also used to define identifiers whose values can be tested in an
#if...#elif...#else...#endif directive.
Syntax
#define <identifier> [ ["]<value>["] ]
#undef <identifier>
Parameters
<identifier>
The text that will be replaced.
<value>
The value that will replace <identifier>.
#undef
Defines the end of the region over which a #define directive operates.
Remarks
If an #undef directive is specified after the #define directive, all occurrences of <identifier> between the #define directive and the #undef directive will be replaced with the value of value. If no #undef directive is specified, all occurrences of <identifier> between the #define directive and the end of the source file will be replaced.
If the region over which the substitution occurs includes any
#include directives, any occurrences of
<identifier> in those include files will also be replaced with the value of
<value>. You can use this feature to create include files that contain variables whose values will be defined in the source file.
If
<value> is supplied, enclose it in quotation marks unless a numeric identifier is being defined for use with an
#if...#elif...#else...#endif directive.
If <value> is not supplied, <identifier> is replaced with a zero length string.
The search for <identifier> is case-sensitive, and identifiers that occur within string literals (quoted strings) are not replaced.
For more information about using the
#define directive in data management scripts, see
Using text substitution in the DMS file.
Example
The following example uses the #define directive to replace text in an include file. All occurrences of “TargetDDF” and “TargetMDD” in the include file will be replaced with the file locations defined in the two #define directives. The two #undef directives ensure that any further occurrences of “TargetDDF” and “TargetMDD” in the source file will not be replaced:
#define TargetDDF "C:\My Output Data\Survey1.ddf"
#define TargetMDD "C:\My Output Data\Survey1.mdd"
#include "[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Scripts\Data Management\DMS\Include\DDFOutput.dms"
#undef TargetDDF
#undef TargetMDD
See also