Scripting > Using preprocessor directives > #include
 
#include
The #include directive can be used to insert the contents of a file into the source file at the position of the directive.
Syntax
#include "filename"
Parameter
filename
The name and location of the file to include. Paths can be relative or absolute.
Remarks
Include files are useful for inserting commonly used routines into a source file. The routine needs to be written only once and can then be included in any source file that requires that routine. An include file can also contain preprocessor directives, including the #include directive.
Include files are often of the same file type as the source file. However, you can include a mrScriptBasic (.mrs) file in an event section of a data management script, for example.
The use of include files in data management scripts is described in more detail in Using include files in the DMS file.
Text encoding
Due to a limitation of the mrPrePro preprocessor, you must make sure that your source file and all include files have been saved using the same text encoding option. Currently, only ANSI and Unicode are supported by mrPrePro for include files. Generally, you should save your source and include files using the ANSI option, but if either your source file or any include file contains non-Western European characters, you must save the source file and all include files using the Unicode option.
The UTF-8 text encoding option must only be used when saving source files that do not contain #include directives.
Example
The following example uses the #include directive to insert the contents of a .mrs file into a mrScriptBasic script. The .mrs file contains a mrScriptBasic function called FormatOrdinal:
#include "[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Scripts\General\mrScriptBasic\FormatOrdinalFunction.mrs"

Dim MyOrdinal

MyOrdinal = FormatOrdinal(MyValue)
See also
Using preprocessor directives