Syntax:

#include <filename.h>
#include "absolutePath.h"

#define NAME    value

C/C++ Users: syntax and usage for #define and #include are equivalent to C/C++ usage.  Note that macros are not supported, use a function instead.

General:
The preprocessor is a "first-pass" by the compiler.  This allows you to expand the code in your script with little effort.  The #include directive tells the preprocessor to take the contents of the file specified and paste it into the script that #include's it.  We have provided a header file with messiah called messiah.h that contains definitions for many common values (such as motion channel ID's, logical values like TRUE and FALSE, and values for working with vectors).  You can include this file with your script by calling:

#include <messiah.h>

at the beginning of your script.  When you use <> to enclose the header file name you are telling the preprocessor that the script is in the "include path".  This path is messiah/modules/scripts/include.  When you are referring to a header that is not in the include path you must enclose it in " "'s and give it an absolute path. 

Note: Use (UNIX style) forward slashes, '/', in your paths.  Do not use (DOS style) backslashes, '\'. 

#include "c:/my_includes/blarg.h"    // OK
#include "c:\my_includes\blarg.h"    // ERROR: don't use backslashes

For now the only things that should be placed in a header file are preprocessor directives, that is #includes and #defines, do not define variables or functions in a header.

Defines are like a search-and-replace that the preprocessor does before it compiles the script.  It may look like we are declaring a variable but that is far from true.  When we define a "constant" as follows:

#define MY_PI    3.14159

we are telling the preprocessor to replace every occurrence of MY_PI in our script with the characters: 3.14159. This is a TEXT replacement. You cannot assign a value to a #define'd symbol:

#define TEST    'a'

TEST = 'b';    // ERROR: expands to 'a' = 'b';

As you see in the comment, TEST expands to the characters: 'a' once the preprocessor does it's thing; you certainly can't assign a value to a constant.  We refer to these values as "constants" because, well they don't vary.  It is strongly advised that you place all of your defines for your script(s) in a header file, this makes it easy to find and change constants when necessary.

You can use defines in defines like so:

#define TRUE    1
#define true    TRUE

As long as the define that's being used in another define has already been defined (say that ten time fast).  In other words we can use TRUE in the definition of 'true' only because TRUE has already been defined.

You can also use #define to create a symbol for an expression:

#define SQ_2_3    sqrt(2)*3

It is advised however that you enclose your defined expressions in parentheses to avoid possible confusion during the preprocessor stage:

#define SQ_2_3    (sqrt(2)*3)

Important: Since #define's are a text replacement you should not include a semi-colon at the end of the definition (otherwise you will be adding a semi-colon to your script wherever you use that symbol).  In general you should not use a semicolon at the end of any preprocessor directive, they are not statements.

Style Note: By convention #define'd symbols are usually all uppercase to identify them in the script as symbols and not variables.  In messiah.h we have included some lower case versions of these symbols to be consistent with Command mode expressions and other programming languages.

Converted from CHM to HTML with chm2web Pro 2.82 (unicode)