| Syntax |
Description |
Sample |
| #define [name] |
The define directive marks the identifier [name] as existing. Marking an indentifier as existing is used to include JavaScript code fragments conditionally, based on existance/non-existance of given identifier (using #ifdef and #ifndef directives). |
#define GENERATE_IE_CODE
...
#ifdef GENERATE_IE_CODE
// the code in this block
// will be included
#else
// this code will not be included
#endif |
| #define [name] [value] |
This version of the define directive servers two purposes: it marks the identifier [name] as existing and it also will replace all occurrences of text [name] with [value] in all lines of the code following this define directive |
#define SCRIPT_VERSION 5.0 BETA
...
alert ("Script version is SCRIPT_VERSION");
// the above line will display:
// Script version is 5.0 BETA |
| #undef [name] |
Marks the identifier [name] as non-existing (reverses the action of the corresponding #define directive). |
#define INSERT_DEBUG_CODE
...
#ifdef INSERT_DEBUG_CODE
// this code will be inserted
#endif
...
#undef INSERT_DEBUG_CODE
#ifdef INSERT_DEBUG_CODE
// this code will NOT be inserted
#endif
|
| #allundef |
Marks all previously defined identifiers as non-existing. |
#define INSERT_DEBUG_CODE
...
#ifdef INSERT_DEBUG_CODE
// this code will be inserted
#endif
...
#allundef
#ifdef INSERT_DEBUG_CODE
// this code will NOT be inserted
#endif
|
#ifdef [name]
[code A]
#endif
or
#ifdef [name]
[code A]
#else
[code B]
#endif |
Conditionally includes code. In case that an identifier named [name] is existing, [code A] will be included in the optimized version of the code. If using the second variant (with the #else directive), [code A] will be included if [name] exists; otherwise [code B] will be included. Please note that each #ifdef directive must be matched by a closing #endif directive. You can use an #ifdef directive inside other #ifdef directives (thus forming a complex AND condition). |
#define INSERT_DEBUG_CODE
...
#ifdef INSERT_DEBUG_CODE
// this code will be inserted
#ifdef ABC
// this code will NOT be inserted
// since ABC is not defined
// and we'd need both ABC
// and INSERT_DEBUG_CODE here
#endif
#endif
...
#ifdef INSERT_DEBUG_CODE
// this code will also be inserted
#else
// this code will NOT be inserted
#endif
|
#ifndef [name]
[code A]
#endif
or
#ifndef [name]
[code A]
#else
[code B]
#endif |
Conditionally includes code. In case that an identifier named [name] does NOT exist, [code A] will be included in the optimized version of the code. If using the second variant (with the #else directive), [code A] will be included if [name] DOES NOT exists; otherwise [code B] will be included. Please note that each #ifndef directive must be matched by a closing #endif directive. You can use an #ifndef directive inside other #ifdef or #ifndef directives. |
#define INSERT_DEBUG_CODE
...
#ifndef ABC
// this code will be inserted
#endif
...
#ifndef INSERT_DEBUG_CODE
// this code will NOT be inserted
#endif
...
#ifndef INSERT_DEBUG_CODE
// this code will NOT be inserted either
#else
// this code will be inserted
#endif
|
| #include "[file]" |
Includes the contents of file found at location specified by [file]. WARNING: This is not supported in the online version. |
#include "abc.js" |