Export (0) Print
Expand All

Conditional Compilation Variables

The following predefined variables are available for conditional compilation.

Variable Description
@_win32 true if running on a Win32 system, otherwise NaN.
@_win16 true if running on a Win16 system, otherwise NaN.
@_mac true if running on an Apple Macintosh system, otherwise NaN.
@_alpha true if running on a DEC Alpha processor, otherwise NaN.
@_x86 true if running on an Intel processor, otherwise NaN.
@_mc680x0 true if running on a Motorola 680x0 processor, otherwise NaN.
@_PowerPC true if running on a Motorola PowerPC processor, otherwise NaN.
@_jscript Always true.
@_jscript_build The build number of the JScript scripting engine.
@_jscript_version A number representing the JScript version number in major.minor format.
@_debug true if compiled in debug mode, otherwise false.
@_fast true if compiled in fast mode, otherwise false.
Note   The version number reported for JScript .NET is 7.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.

See Also

Conditional Compilation | Conditional Compilation Directives | Conditional Compilation Statements | Detecting Browser Capabilities

Show:
© 2014 Microsoft