#define and #undef
The #define directive can be used to substitute text in a source file. The #undef directive can then be used 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 not supplied,
identifier will be replaced with a zero length string. If
value is supplied, it should always be enclosed in quotation marks unless a numeric identifier is being defined for use with an
#if...#elif...#else...#endif directive.
The search for identifier is case sensitive, and identifiers that occur within string literals (quoted strings) are not replaced.
The use of the
#define directive in data management scripts is described in more detail in
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