JScript ÊÇÓÉ΢Èí¿ª·¢µÄ»î¶¯½Å±¾ÓïÑÔ£¬»ùÓÚ ECMAScript ¹æ·¶ÊµÏÖ¡£Internet Explorer ÖÐµÄ JavaScript£¬Êµ¼ÊÉÏÊÇÖ¸ JScript¡£JScript Òѱ» Windows Script Host£¨WSH£©Ö§³Ö£¨WSH ÖÐµÄ JavaScript shell scripting£ºC:\> cscript jslint.js£©¡£JScript ×îеİ汾£¨JScript.NET£©»ùÓÚ ECMAScript 4.0 £¬²¢ÇÒ¿ÉÒÔÔÚ .Net »·¾³Ï±àÒë¡£
.NET Framwork Öаüº¬ÓÐ JScript ±àÒëÆ÷ £ºJScriptCompiler£¨C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\jsc.exe£©£¬Æä¿ÉÒÔ½« JScript Îļþ±àÒëΪһ¸ö .exe »òÕß .dll Îļþ¡£
ΪÁË·½±ãʹÓã¬ÎÒÃÇ¿ÉÒÔ½« JScriptCompiler µÄ·¾¶¼ÓÈëµ½»·¾³±äÁ¿£¨»·¾³±äÁ¿ –> ϵͳ±äÁ¿ –> Path£©ÖС£ÔÚ CMD ³ÌÐòÔËÐд°¿ÚÖÐÖ±½Óµ÷ÓÃÃüÁî “jsc”£¬¾Í¿ÉÒÔ¿´µ½±àÒëÆ÷Ïà¹ØµÄ°ïÖúÑ¡Ïî¡£
jsc [Ñ¡Ïî] <Ô´Îļþ> [[Ñ¡Ïî] <Ô´Îļþ>…]
JScript ±àÒëÆ÷Ñ¡Ïî
– Êä³öÎļþ -
/out:<file> Ö¸¶¨¶þ½øÖÆÊä³öÎļþµÄÃû³Æ
/t[arget]:exe ´´½¨¿ØÖÆ̨ӦÓóÌÐò(ĬÈÏ)
/t[arget]:winexe ´´½¨ Windows Ó¦ÓóÌÐò
/t[arget]:library ´´½¨¿â³ÌÐò¼¯
/platform:<platform> ÏÞÖÆ´Ë´úÂë¿ÉÒÔÔÚÆäÉÏÔËÐеÄƽ̨£»±ØÐëÊÇ x86¡¢Itanium¡¢x64 »ò anycpu¡£Ä¬ÈÏΪ anycpu– ÊäÈëÎļþ -
/autoref[+|-] »ùÓÚµ¼ÈëµÄÃüÃû¿Õ¼äºÍÍêÈ«ÏÞ¶¨Ãû³Æ×Ô¶¯ÒýÓóÌÐò¼¯(ĬÈÏÇé
¿öÏÂΪ on)
/lib:<path> Ö¸¶¨ÒªÔÚÆäÖÐËÑË÷ÒýÓõĸ½¼ÓĿ¼
/r[eference]:<file list> ´ÓÖ¸¶¨µÄ³ÌÐò¼¯ÎļþÒýÓÃÔªÊý¾Ý <file list>: <assembly name>[;<assembly name>...]– ×ÊÔ´ -
/win32res:<file> Ö¸¶¨ Win32 ×ÊÔ´Îļþ(.res)
/res[ource]:<info> ǶÈëÖ¸¶¨µÄ×ÊÔ´ <info>: <filename>[,<name>[,public|private]]
/linkres[ource]:<info> ½«Ö¸¶¨µÄ×ÊÔ´Á´½Óµ½´Ë³ÌÐò¼¯ <info>: <filename>[,<name>[,public|private]]– ´úÂëÉú³É -
/debug[+|-] ·¢³öµ÷ÊÔÐÅÏ¢
/fast[+|-] ½ûÓÃÓïÑÔ¹¦ÄÜÒÔʹ´úÂë¸üºÃµØÉú³É
/warnaserror[+|-] ½«¾¯¸æÊÓΪ´íÎó
/w[arn]:<level> ÉèÖþ¯¸æµÈ¼¶(0-4)– ÔÓÏî -
@<filename> Óйظü¶àÑ¡ÏÇëÔĶÁÏìÓ¦Îļþ
/? ÏÔʾ°ïÖú
/help ÏÔʾ°ïÖú
/d[efine]:<symbols> ¶¨ÒåÌõ¼þ±àÒë·ûºÅ
/nologo ²»ÏÔʾ±àÒëÆ÷°æȨ±êÖ¾
/print[+|-] Ìṩ print() º¯Êý– ¸ß¼¶ -
/codepage:<id> ʹÓÃÖ¸¶¨µÄ´úÂëÒ³ ID ´ò¿ªÔ´Îļþ
/lcid:<id> ½«Ö¸¶¨µÄ LCID ÓÃÓÚÏûÏ¢ºÍĬÈÏ´úÂëÒ³
/nostdlib[+|-] ²»µ¼Èë±ê×¼¿â(mscorlib.dll)²¢½« autoref ĬÈÏÖµ¸ü¸ÄΪ off
/utf8output[+|-] ÒÔ UTF-8 ×Ö·û±àÂëÐÎʽ·¢³ö±àÒëÆ÷Êä³ö
/versionsafe[+|-] ΪûÓбê¼ÇΪ“override”»ò“hide”µÄ³ÉÔ±Ö¸¶¨Ä¬ÈÏÖµ
´´½¨ .exe Îļþ
ÏÈ´´½¨ JS Îļþ£¨C:\test\helloWorld.js£©£¬ÄÚÈÝÈçÏ£º
var date = new Date(); print('Hello World! \nToday is ' + date );
½Ó×ÅÎÒÃǽøÐбàÒ룺
C:\test>jsc helloWorld.js Microsoft (R) JScript Compiler version 8.00.50727 for Microsoft (R) .NET Framework version 2.0.50727 Copyright (C) Microsoft Corporation 1996-2005¡£±£ÁôËùÓÐȨÀû¡£
Äã»á¾ªÑȵķ¢ÏÖ£¬C:\test Ŀ¼Ï¶àÁ˸ö helloWorld.exe Îļþ£¬·Ç³£¼òµ¥°É£¬ºÇºÇ
×îºóÎÒÃÇ¿ÉÒÔÖ±½ÓÖ´ÐÐ helloWorld.exe Îļþ£º
C:\test>helloWorld Hello World! Today is Fri Jun 3 23:13:20 UTC+8 2011
´ó¹¦¸æ³É£¡£¡
´´½¨ .dll Îļþ
.dll ÎļþµÄ´´½¨Ò²Í¬Ñù·Ç³£¼òµ¥£º
package LibHW { class HelloWorld { function run() { var date = new Date(); return 'Hello World! \nToday is ' + date; } } }
±àÒëÓï¾ä£º
C:\test>jsc /t:library LibHW.js
¶ÔÓÚÉú³ÉµÄ LibHW.dll Îļþ£¬ÎÒÃÇ¿ÉÒÔͨ¹ý´´½¨Ð嵀 .exe Îļþ£¨consumer.js –> consumer.exe£©ÒÔµ¼ÈëÄ£¿éµÄ·½Ê½µ÷Óã¨ÀàËÆÓÚ Python£©¡£
ÏÈ´´½¨ consumer.js Îļþ£º
import LibHW; var hw = new LibHW.HelloWorld(); print(hw.run());
È»ºó±àÒë consumer.js Îļþ£¬Ö´ÐÐ consumer.exe£º
C:\test>jsc consumer.js Microsoft (R) JScript Compiler version 8.00.50727 for Microsoft (R) .NET Framework version 2.0.50727 Copyright (C) Microsoft Corporation 1996-2005¡£±£ÁôËùÓÐȨÀû¡£ C:\test>consumer Hello World! Today is Sat Jun 4 00:42:35 UTC+8 2011
µ±È»Ä㻹¿ÉÒÔ´´½¨ windows µÄÓ¦Óã¬ÉÏÀýÖÐµÄ consumer.js ÎļþÐÞ¸ÄÈçÏ£º
import System.Windows.Forms; // this has a MessageBox class import LibHW; var hw = new LibHW.HelloWorld(); MessageBox.Show( hw.run(), "Dude!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
±àÒëÓï¾ä£º
C:\test>jsc /t:winexe consumer.js
Ë«»÷ÐÂÉú³ÉµÄ consumer.exe Îļþ£¬¹þ¹þ£¬ÊDz»ÊǺÜÓгɾ͸У¡
´ÓÉÏÃæµÄÀý×Ó¿ÉÒÔ¿´µ½ JScript µÄDZÁ¦ÎÞÏÞ£¬Ã»ÓÐ×ö²»µ½£¬Ö»ÓÐÏë²»µ½¡£
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-797-1.html