Detailed description of condition annotations in JScript and detailed description of jscript annotations

Source: Internet
Author: User

Detailed description of condition annotations in JScript and detailed description of jscript annotations

JScript can use the following statements to compile variable values to control script compilation. You can either use the variables provided by JScript or use the @ set command or the/define command line option to define your own variables.

@ Cc_on
Activation condition compilation is supported.
 
@ If
Execute a group of statements conditionally based on the expression value.
 
@ Set
Create a variable that uses the Conditional compilation statement.
 
@ Cc_on, @ if, or @ set statement activation condition compilation. Some typical uses of Conditional compilation include using new features in JScript, embedding debugging support into a script, and tracking code execution.

When writing scripts run by Web browsers, Conditional compilation code is always put in comments. Therefore, the code can be ignored by hosts that do not support conditional compilation. This is an example.

Copy codeThe Code is as follows:

/* @ Cc_on @*/
/* @ If (@ _ jscript_version> = 5)
Document. write ("JScript Version 5.0 or better. <BR> ");
@ Else @*/
Document. write ("You need a more recent script engine. <BR> ");
/* @ End @*/


In this example, special annotation delimiters are used only after the @ cc_on statement activates Conditional compilation. The Conditional compilation script engine does not support displaying a message. We recommend that you use a new script engine without generating errors. The engine that supports Conditional compilation compiles the first or second document. write according to the engine version. Note that version 7.x represents JScript. NET. For more information, see the browser detection function.

Conditional compilation is also useful for server scripts and command line programs. In these applications, you can use Conditional compilation to compile other functions into one program for analysis in debugging mode.


The following predefined variables can be used for Conditional compilation.

@ _ Win32
If the/platform option is not specified or the/platform: anycpu option is specified, the parameter is true; otherwise, the parameter is NaN.
 
@ _ Win16
True if running on the Win16 system; NaN if not.
 
@ _ Mac
True if running on the Apple Macintosh system; NaN if not.
 
@ _ Alpha
True if running on the DEC Alpha processor; NaN if not.
 
@ _ X86
True if the/platform option is not specified or the/platform: anycpu option is specified on the Intel processor; otherwise, NaN is used.
 
@ _ Mc680x0
True if running on the Motorola 680x0 processor; otherwise, NaN.
 
@ _ PowerPC
True if running on the Motorola PowerPC processor; otherwise, NaN.
 
@ _ Jscript
Always true.
 
@ _ Jscript_build
The internal version number of the JScript engine.
 
@ _ Jscript_version
The number of the JScript version in major. minor format.
 
@ _ Debug
It is true if it is compiled in debug mode; otherwise, it is false.
 
@ _ Fast
It is true if it is compiled in quick mode; otherwise, it is false.
 
Note:
The JScript. NET Report version is 7.x. The JScript 8.0 report version is 8.x.
 
You must enable Conditional compilation before using Conditional compilation. The @ cc_on statement can enable Conditional compilation. Conditional compilation variables are usually used in scripts written for Web browsers. Conditional variables are rarely used in scripts written for ASP, ASP. NET pages, or command line programs, because you can use other methods to determine compiler compatibility.

When writing scripts for Web pages, the Conditional compilation code is always put in comments. In this way, the code can be ignored by hosts that do not support conditional compilation. This is an example.


Copy codeThe Code is as follows:

/* @ 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
@*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.