|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Conditional Compilation Variables
The following predefined variables are available for conditional compilation.
true if running on a Win32 system and the /platform option is not specified or the /platform:anycpu option is specified, otherwise NaN.
true if running on a Win16 system, otherwise NaN.
true if running on an Apple Macintosh system, otherwise NaN.
true if running on a DEC Alpha processor, otherwise NaN.
true if running on an Intel processor and the /platform option not specified or /platform:anycpu option is specified, otherwise NaN.
true if running on a Motorola 680x0 processor, otherwise NaN.
true if running on a Motorola PowerPC processor, otherwise NaN.
The build number of the JScript scripting engine.
A number representing the JScript version number in major.minor format.
true if compiled in debug mode, otherwise false.
true if compiled in fast mode, otherwise false.
The version number reported for JScript .NET is 7.x. The version number reported for JScript 8.0 is 8.x.
Before using a conditional compilation variable, conditional compilation must be turned on. The @cc_on statement can turn on conditional compilation. Conditional compilation variables are often used in scripts written for Web browsers. It is not so common to use conditional compilation variables in scripts written for ASP or ASP.NET pages or command-line programs since the capabilities of the compilers can be determined using other methods.
When writing a script for a Web page, always place conditional compilation code in comments. This allows hosts that do not support conditional compilation to ignore it. Here is an example.
/*@cc_on document.write("JScript version: " + @_jscript_version + ".<BR>"); @if (@_win32) document.write("Running on 32-bit Windows.<BR>"); @elif (@_win16) document.write("Running on 16-bit Windows.<BR>"); @else document.write("Running on a different platform.<BR>"); @end @*/
Conditional compilation variables can be used to determine the version information of the engine interpreting a script. This allows a script to take advantage of the features available in the latest versions of JScript while maintaining backwards compatibility. For more information, see Detecting Browser Capabilities.