Script Preprocessor Directives

Introduction:

WVS scripting engine implements a basic preprocessor to have functionality like include which the JScript engine lacks.

Preprocessing directives must be on the first non-empty and non-comment line of a script. Any directives located elsewhere will not be parsed by the preprocessor and will be passed to the JScript scripting engine where they most probably will produce a syntax error. Each directive start with an # and must be in separate line.

Example:

#include "testInclude.inc"; // include some script #engine "1.3"; // this script requires at least v1.3 engine #require "someOtherScript.script"; // the script will only run if the other script was executed ...

List of Directives:

#include

The #include directive will try to include (merge) another script with the current, at the position where the include directive appears.

#include directive has a single parameter which represents the name of the file that should be included. On parsing the preprocessor will look for the file in the following directories: absolute path or the directory from which the script is executed, include directories; in that exact order.

The directory [ApplicationDirectory]\Data\Scripts\Includes is automatically added to the include directories list, being the prefered directory for shared include files.

If the preprocessor is unable to include at least one of the files listed as include, the script will not be executed and an error message will be put in the logs.

#engine

By the #engine directive a script can tell to the preprocessor what is the minimum required script engine which is needed for it to execute. The version parameter should be in the [high version number].[low version number] format.

If the preprocessor detects a script engine which is older than the required one, the script will not be executed and an error message will be put in the logs.

#require

With the #require directive the script can condition it's execution on another script. Script engine will not execute the script only if the required script has been executed. If the required script was not yet executed, the engine will postpone the execution of the current script. If the required script has been disabled or is inexistent, the script will not be executed and an error message will be put in the logs.