JScript can use the following statement to control the compilation of a script based on the value of a conditional compilation variable. You can use either the variables provided by JScript, or you can define your own variables by using the @set directive or the/define command-line option.
When you write a script that is run by a Web browser, you always place conditional compilation code in a comment. Therefore, a host that does not support conditional compilation can ignore the code. This is an example.
This example uses special annotation delimiters that are used only after the @cc_on statement activates the conditional compilation. Script engines that do not support conditional compilation display a message suggesting that a new scripting engine needs to be used without an error. The engine that supports conditional compilation compiles the first or second document.write based on the version of the engine. Note that the 7.x version represents JScript. NET. For more information, see Detecting Browser capabilities.
Conditional compilation is also useful for server-side scripting and command-line programs. In these applications, conditional compilation can be used to compile other functions into a program that is easy to analyze in debug mode.
The following predefined variables are available for conditional compilation.
@_win32
True if the/platform option is not specified or the/PLATFORM:ANYCPU option is specified when running on the WIN32 system;
@_win16
True if running on the Win16 system, otherwise NaN.
@_mac
True if running on Apple Macintosh system, otherwise NaN.
@_alpha
True if running on the DEC Alpha processor, otherwise NaN.
@_x86
True if it is running on an Intel processor and the/platform option is not specified or the/PLATFORM:ANYCPU option is specified;
@_mc680x0
True if running on the Motorola 680x0 processor, otherwise NaN.
@_powerpc
True if running on the Motorola PowerPC processor, otherwise NaN.
@_jscript
is always true.
@_jscript_build
The build number of the JScript script engine.
@_jscript_version
A number that represents the JScript version number in major.minor format.
@_debug
True if compilation is in debug mode, otherwise false.
@_fast
True if compilation is in quick mode, otherwise false.
Attention
The version number of the JScript. NET report is 7.x. The version number of the JScript 8.0 report is 8.x.
Before you can use conditional compilation variables, you must first open conditional compilation. @cc_on statement to open conditional compilation. Conditional compilation variables are typically used in scripts written for Web browsers. Conditional compilation variables are rarely used in scripts written for ASP or asp.net pages or command-line programs because other methods can be used to determine compiler compatibility.
When you write a script for a Web page, you always place the conditional compilation code in a comment. This allows a host that does not support conditional compilation to ignore the code. This is an example.
Copy Code code as follows: