Directives

The MSL language is normally used in conjunction with a preprocessor, which allows for conditional inclusion and/or replacement of text. As such, additional flexibility is provided.

The following directives can be used in MSL code:

#include
The #include directive instructs the WESTŪ model compiler to include the file specified by the #include statement into the processed code. The name of this file must be enclosed by double quotes (or angle brackets).

Example:

#include "generic.msl"
#define
The #define directive is used to declare a preprocessor identifier and/or specify a value for it.

Example 1:

#define WWTP
The identifier "WWTP" is defined, but no value is assigned to it.

Example 2:

#define NrOfLayers 10
The identifier "NrOfLayers" is defined and assigned to a value of 10.
#if, #else, #endif, #ifdef, #if defined
These are conditional directives that allow for processing selected parts of a file. The general idea behind the #if directive is that if the expression following the #if is true, the part between the #if and the #endif directive is processed; otherwise this portion is skipped. The #else directive provides an alternative if the #if fails. The #endif directive is used to mark the end of an #if block.

The directive #ifdef is equivalent to #if defined and is true when the identifier following the directive has been defined before.

Example 1:

#if ASM2
// The statements between #if and #else are processed if the identifier ASM2 is specified
#else
 // The statements between #else and #endif are processed if the identifier ASM2 is not specified
#endif

Example 2:

#if (defined ASM2 || defined ASM2d)
 // The statements between #if and #endif are processed if ASM2 or ASM2d is specified
#endif
#ifndef
The #ifndef directive means "if not defined". The #else directive provides an alternative if the #ifndef fails.

Example:

#ifndef WWTP
#define WWTP
// If not previously defined: define the identifier WWTP
#endif