Use JScript.net to write. net Applications

Source: Internet
Author: User

Javascript is a magic language, flexible, easy to learn, and advanced in concept. But now it seems to have been pinned on the browser. In fact, this is the biggest misunderstanding of javascript. MS. the net platform provides full-featured JScript support. However, this JScript complies with the ECMA standard. Like M $'s attitude towards other international standards, JScript adds many other capabilities, so people accidentally bound them to windows. But it doesn't matter. Our topic this time is to write a. net program. It doesn't matter if it is bound. Who makes me a "drop-down to MS"? In fact, I basically don't want to go through money.

After. net sdkis installed, jsc.exe is installed. Before official use, we need to set up an integrated compilation environment. bigtall uses UltraEdit, so a new command is created in the menu "Advanced/tool configuration: the menu item name is "JScript.net compilation". Command Behavior: C: WindowsMicrosoft.NETFrameworkv2.0.50727jsc.exe/fast-"% f"; working directory: % p; remember to set "output" to "output to list box" and save it.

 

With the environment, we can start to write some test code. First, create a test. js, standard javascript code:

 

 

Var arr = ["a", "B"];
Var obj = {name: "test", value: 3.0 };
Print (arr [0]);
Print (arr [1]);
Print (obj. name );
Print (obj. value );

Run the following menu command to compile successfully. A test.exe file is displayed in the current directory. It runs normally!

 

 

If you want to compile a complete program, I am afraid one file is not enough. So let's test the compilation of multiple files and create a mod. js file with the following content:

 

Function hello ()
{
This. name = "haha ";
}
Function haha ()
{
Print ("call haha ");
}

Then we modify test. js as follows:

 

Var arr = ["a", "B"];
Var obj = {name: "test", value: 3.0 };
Print (arr [0]);
Print (arr [1]);
Print (obj. name );
Print (obj. value );
Import mod;
Var t = new hello ();
Print (t. name );

However, compilation is learned. We need to compile it manually. In cmd, enter jsc/fast-mod. js test.jsto compile a mod.exe file and run it! However, if we compile and run the jsc/fast-test. js mod.js command, the test.exe cannot be run because we cannot find things in mod. js. This is an important part of attention.

 

 

Because JScript has made a lot of extensions, we need to test whether the extension commands and non-extensions can cooperate with each other, because we need to compile. and. net programs.. net SDK. It is necessary to use extensions. Create a new file pkg. js with the following content:

Import System;
Package France. Paris {
Public class Landmark {
Static var Tower: String = "Eiffel Tower ";
Function p ()
{
System. Console. WriteLine ({t: "hello from writeline"}. t );
}
}
};

Modify test. js as follows:

Var arr = ["a", "B"];
Var obj = {name: "test", value: 3.0 };
Print (arr [0]);
Print (arr [1]);
Print (obj. name );
Print (obj. value );
Var t = new hello ();
Print (t. name );
Haha ();
Print (France. Paris. Landmark. Tower );
Import France. Paris;
New Landmark (). p ();

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.