Compiler directives

From ZCWiki
Jump to navigationJump to search

Compiler directives instruct the ZScript compiler to perform various actions prior to compiling a ZScript. They are similar in concept to C/C++ pre-processor commands or directives (such as #include). Compiler directives should be placed at the top of a script file, prior to any global variable or script declarations.


The import directive instructs the ZScript compiler to include another ZScript file in the compilation. Syntax is as follows:

import "filename"

where filename is the name (including extension, typically .z or .zh) of the file to include in the compilation. The filename to be included is relative to ZQ's working directory. Note that you do not end the line with a semicolon. Also note the use of double-quotes.

The import directive performs a blind direct inclusion of the specified file into the current file. In particular, the compiler performs no checks to stop the same file from being imported twice.

The most important use of this directive is to include the std.zh file in the compilation. The std.zh file defines several constants you can use to keep your code more maintainable and easier to read.