JScript - Documentation & Help · JScript JScript C++ JScript JScript JScript Java JScript...

Preview:

Citation preview

JScript

JScript

Jscript

InternetJScript

JScript

FlieSystemObject

Script

©2000MicrosoftCorporation

JScript

JScript

JScript

JScript

©2000MicrosoftCorporation

JScript

JScript

Jscript

JScript

JScript

JScript

JScript

JScript

JScript

JScript

©2000MicrosoftCorporation

JScript

JScript

JScriptMicrosoftECMA262ECMAScript3JScriptECMAJScript

JScript

JScriptC++JScriptJScript

JScriptJavaJScript“”ActiveServerPagesASPInternetWindows

JScriptJScriptJScriotJScript

JScript

Web

©2000MicrosoftCorporation

JScript

JScript

MicrosoftJScript “”

JScriptJscriptJscript

“;”(;)JScriptJscript

aBird="Robin";//“ Robin” aBirdvartoday=newDate();// today

{}JScriptJScript for while

JscriptC++

functionconvert(inches){feet=inches/12;//miles=feet/5280;nauticalMiles=feet/6080;cm=inches*2.54;meters=inches/39.37;}km=meters/1000;//kradius=km;mradius=miles;

JScript(//)

aGoodIdea="Commentyourcodethoroughly.";//

(/*),(*/)

/*

aGoodIdea

*/

JScript*/JScript

//

// aGoodIdea////aGoodIdea

varextendedIdea=aGoodIdea+"Youneverknowwhenyou'llhavetofigureoutwhatitdoes.";

JScript(=)=LvalueLvalue

=RvalueRvaluesJScript

anInteger=3;

Jscript“3anInteger”“anInteger3”

===(==)

JScriptJScriptJScript“”JScript—JScript

3.9//"Hello!"//false//null//{x:1,y:2}//[1,2,3]//function(x){returnx*x;}//

+//-//*/////

JScript

varanExpression=3*(4/5)+6;varaSecondExpression=Math.PI*radius*radius;varaThirdExpression=aSecondExpression+"%"+anExpression;varaFourthExpression="("+aSecondExpression+")%("+anExpression+")";

©2000MicrosoftCorporation

JScript

JScript

HowoldamI?

Jscript

NumberOfDaysLeft=EndDate–TodaysDate;

var

varcount;//varcount,amount,level;// varvarcount=0,amount=100;//

varJScript undefined varJScriptJScript var

Jscript

JScript myCounter mYCounter

ASCII(_)

_pagecountPart9Number_Items

99Balloons//Smith&Wesson//“” &

JScript null

varbestAge=null;varmuchTooOld=3*bestAge;//muchTooOld 0

Jscript undefined

varcurrentCount;varfinalCount=1*currentCount;//finalCount NaN

JScript null undefined null0 undefinedNaN null undefined

var

noStringAtAll="";// noStringAtAll

varvolume=length*width;// —lengthwidth

JScriptJscript

JScriptC++JScript

JscriptJScriptJScript

varx=2000;//vary="Hello";//x=x+y;//document.write(x);// 2000Hello

parseInt parseFloat

©2000MicrosoftCorporation

JScript

JScript

Jscript

Null

Undefined

UnicodeJScript

"HappyamI;fromcareI’mfree!"'"Avast,yelubbers!"roaredthetechnician.'"42"'c'

JScriptC++ charJscript""

JscriptJScriptJScript

010816Jscript“0”807“0”“8”“9”

“0x”x|X1609AFAF10150xF150x1016

“e”10JscriptIEEE754±1.7976931348623157x10308±5x10-324“0”

“0x”“00”Jscript

.0001,0.0001,1e-4,1.0e-4 0.00013.45e2 34542 420378 08 3780377 1 2550.0001 0.000100.0001 N/A0Xff 2550x37CF 142870x3e7 ‘e’ 9990x3.45e2 N/A

JScript

NaN

JScript

JScript

00Jscript00

Boolean

boolean true falseBoolean

BooleanJscript

y=(x==2000);

x2000Boolean trueyx2000boolean false

BooleanbooleanbooleanJScript

if(x==2000)z=z+1;elsex=x+1;

boolean trueJscript if/elsez=z+1booleanfalsex=x+1

0null false true

if(x=y+z)// –

xy+zy+zxxy+z

if(x==y+z)//

Null

Jscript nullnullnull

null“”“”booleannull

Jscriptnull0CC++Jscript typeofnull Objectnull

Undefined

undefined

undefined“undefined”x

//if(x==undefined)//

// -// "undefined"if(typeof(x)==undefined)//

//if(typeof(x)=="undefined")//

undefinednull

someObject.prop==null;

true

someObject.propnull

someObject.prop

in

if("prop"insomeObject)

//someObject 'prop'

©2000MicrosoftCorporation

JScript

JScript

JScript,

- ! ~ = delete++ < << oP= typeof typeof-- > >> void void* <= >>> instanceof instanceof/ >= & new new% == ^ in in+ != | - &&

|| ?: , === !==

====="1"1true"1"1

ArrayFunctionStringNumberBooleanErrorDateRegExptrue

//varstring1="Hello";varstring2="Hello";

// StringvarStringObject1=newString(string1);varStringObject2=newString(string2);

// trueif(string1==string2)

//

// falseif(StringObject1==StringObject2)//

// String //toString() valueOf()if(StringObject1.valueOf()==StringObject2)//

©2000MicrosoftCorporation

JScript

Jscript

“”“”Boolean true false

Jscript

if

if/else

?:

switch

Jscript

while

do/while

for/in

for

JScript if if...else ifJScript if...else if if if...else

if if...else true if

//smash()// newShip trueif(newShip)smash(champagneBottle,bow);

//if(rind.color=="deepyellow"&&rind.texture=="largeandsmallwrinkles"){theResponse=("IsitaCrenshawmelon?");}

//vartheReaction="";if((dayOfWeek=="Saturday")||(dayOfWeek=="Sunday")){theReaction=("I'mofftothebeach!");}else{theReaction=("Hiho,hiho,it'sofftoworkIgo!");}

JScript if

varhours="";

// hours theHour// theHour-12

hours+=(theHour>=12)?"PM":"AM";

“”JScript

“”((x==123)&&(y==42))Jscriptx123y42trueyJscript false

||OR trueANDfalse

runfirst()0 false runsecond()

if((runfirst()==0)||(runsecond()==0)){//}

JScript for for...in while do...while

for

for

/* "icount++"

*/

varhowFar=10;// 10

varsum=newArray(howFar);// sum 10vartheSum=0;sum[0]=0;

for(varicount=0;icount<howFar;icount++){//theSum+=icount;sum[icount]=theSum;}

varnewSum=0;for(varicount=0;icount>howFar;icount++){//newSum+=icount;}

varsum=0;for(varicount=0;icount>=0;icount++){//sum+=icount;}

for...in

JScript for...in

Internet alertJscript

//varmyObject=newObject();myObject.name="James";myObject.age="22";myObject.phone="5551234";

//for(propinmyObject){// "Theproperty'name'isJames"window.alert("Theproperty'"+prop+"'is"+myObject[prop]);}

for...inVBScript ForEach...NextJScript for...inJscriptVBScript ForEach...NextJScript EnumeratorInternetVBScript ForEach...NextJscript for...in

while

while for while“n” whileInternet while

varx=0;while((x!=42)&&(x!=null)){x=window.prompt("Whatismyfavouritenumber?",x);}

if(x==null)window.alert("Yougaveup!");elsewindow.alert("Yep-it'stheUltimateAnswer!");

while while while

JScript do...whilewhile

varx=0;do{x=window.prompt("Whatismyfavouritenumber?",x);}while((x!=42)&&(x!=null));

if(x==null)window.alert("Yougaveup!");elsewindow.alert("Yep-it'stheUltimateAnswer!");

breakcontinue

MicrosoftJscript break break switchfor for...in continue

break continue

varx=0;do{x=window.prompt("Whatismyfavouritenumber?",x);

//if(x==null)break;

////if(Number(x)==x)continue;

//window.alert("Pleaseonlyenterinnumbers!");

}while(x!=42)

if(x==null)window.alert("Yougaveup!");elsewindow.alert("Yep-it'stheUltimateAnswer!");

©2000MicrosoftCorporation

JScript

JScript

MicrosoftJscript“”

Jscript

Jscript eval()Jscript eval()

varanExpression="6*9%7";vartotal=eval(anExpression);// total 5varyetAnotherExpression="6*(9%7)";total=eval(yetAnotherExpression)// total 12// totalityvartotality=eval("’...surroundedbyacresofclams.’");

Jscript

ChecktripletcheckTriplet

“epsilon”

varepsilon=0.00000000001;//

//functionintegerCheck(a,b,c){//if((a*a)==((b*b)+(c*c)))returntrue;

returnfalse;}//

//functionfloatCheck(a,b,c){//vardelta=((a*a)-((b*b)+(c*c)))

//delta=Math.abs(delta);

// epsilon

if(delta<epsilon)returntrue;

returnfalse;}//

//functioncheckTriplet(a,b,c){//vard=0;

//“ a”

// abif(b>a){d=a;a=b;b=d;}

// acif(c>a){d=a;a=c;c=d;

}

// 3if(((a%1)==0)&&((b%1)==0)&&((c%1)==0)){//returnintegerCheck(a,b,c);}else{//returnfloatCheck(a,b,c);}}//

//varsideA=5;varsideB=5;varsideC=Math.sqrt(50.001);

// 'result'varresult=checkTriplet(sideA,sideB,sideC);

©2000MicrosoftCorporation

JScript

JScript

JscriptJscript Internet windowdocumentActiveX

Jscript“” length myArray[100]="hello"— length101 length

Jscript“expando”<<>>

varmyObj=newObject();

// expando 'name''age'myObj.name="Fred";myObj.age=42;

Jscriptexpando

varmyObj=newObject();

// object.property// expando////myObj["notavalididentifier"]="Thisisthepropertyvalue";

// expando//myObj[100]="100";

0 lengthexpandoexpando length

//

varmyArray=newArray(3);

//myArray[0]="Hello";myArray[1]=42;myArray[2]=newDate(2000,1,1);

// 3window.alert(myArray.length);

// expandomyArray.expando="JScript!";myArray["anotherExpando"]="Windows";

// 3 expando//window.alert(myArray.length);Jscript—5

//variMaxNum=5;//vari,j;

// 0// 1 iMaxNum+1varMultiplicationTable=newArray(iMaxNum+1);

//

for(i=1;i<=iMaxNum;i++){//MultiplicationTable[i]=newArray(iMaxNum+1);

//for(j=1;j<=iMaxNum;j++){MultiplicationTable[i][j]=i*j;}}

window.alert(MultiplicationTable[3][4]);// 12window.alert(MultiplicationTable[5][2]);// 10window.alert(MultiplicationTable[1][4]);// 4

©2000MicrosoftCorporation

JScript

pasta this

//pastafunctionpasta(grain,width,shape,hasEgg){//this.grain=grain;

//this.width=width;

//this.shape=shape;

// booleanthis.hasEgg=hasEgg;}

new

varspaghetti=newpasta("wheat",0.2,"circle",true);varlinguine=newpasta("wheat",0.3,"oval",true);

//spaghettispaghetti.color="palestraw";spaghetti.drycook=7;spaghetti.freshcook=0.5;

varchowFun=newpasta("rice",3,"flat",false);//chowFun pasta// spaghetti//

//‘ foodgroup’ pasta// pasta//pasta.prototype.foodgroup="carbohydrates"

// spaghetti.foodgroupchowFun.foodgroup//“ carbohydrates”

pasta toString

//pasta//functionpasta(grain,width,shape,hasEgg){//this.grain=grain;

//this.width=width;

//this.shape=shape;

// booleanthis.hasEgg=hasEgg;

// toString//////this.toString=pastaToString;}

// past functionpastaToString(){

//

return"Grain:"+this.grain+"\n"+"Width:"+this.width+"\n"+"Shape:"+this.shape+"\n"+"Egg?:"+Boolean(this.hasEgg);}

varspaghetti=newpasta("wheat",0.2,"circle",true);// toString() spaghetti// Internetwindow.alert(spaghetti);

©2000MicrosoftCorporation

JScript

MicrosoftJscript11“”ArrayBooleanDateFunctionGlobalMathNumberObjectRegExpErrorString

Array

new Array()

vartheMonths=newArray(12);theMonths[0]="Jan";theMonths[1]="Feb";theMonths[2]="Mar";theMonths[3]="Apr";theMonths[4]="May";theMonths[5]="Jun";theMonths[6]="Jul";theMonths[7]="Aug";theMonths[8]="Sep";theMonths[9]="Oct";theMonths[10]="Nov";theMonths[11]="Dec";

ArrayJscript length0length

vartheMonths=newArray("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

ArrayJscript lengthJscript01length1

String

Jscript string substring

aString="0123456789";varaChunk=aString.substring(4,7);//aChunk "456"varaNotherChunk=aString.substring(7,4);//aNotherChunk//firstLetter=theMonths[5].substring(0,1);// firstLetter

String length0

varhowLong="HelloWorld".length// howLong11

Math

Mathpi3.14159… Math.PI

//varcircleArea=Math.PI*radius*radius;// MathPI

Math powpi

//volume=(4/3)*(Math.PI*Math.pow(radius,3));

Date

Date Date19701100:00:00.000GMTGMTUTC“”“”Jscript250,000B.C.255,000A.D

new Date

/*

“ DayMonthDate00:00:00Year”thisIsToday*/varthisIsToday=newDate();

vartoDay=newDate();//

//varthisYear=toDay.getFullYear();varthisMonth=theMonths[toDay.getMonth()];varthisDay=thisMonth+""+toDay.getDate()+","+thisYear;

Number

Math PIMicrosoftJscript Number

MAX_VALUE 1.79E+308MIN_VALUE 2.22E-308NaN “”POSITIVE_INFINITY Number.MAX_VALUENEGATIVE_INFINITY Number.MAX_VALUE

Number.NaN“”0 NaN Number.NaN NaNNumber.NaN NaN isNaN()

©2000MicrosoftCorporation

JScript

Jscript

JscriptJscript

JscriptJscript

break delete function return typeofcase do if switch varcatch else in this voidcontinue false instanceof throw whiledebugger finally new true withdefault for null try

abstract double goto native staticboolean enum implements package superbyte export import private synchronizedchar extends int protected throwsclass final interface public transientconst float long short volatile

Jscript String parseInt

©2000MicrosoftCorporation

JScript

JScript

©2000MicrosoftCorporation

JScript

new

varmyObject=newObject();//varmyBirthday=newDate(1961,5,10);// DatevarmyCar=newCar();//

this

new Object()Date() Function() this

functionCircle(xPoint,yPoint,radius){this.x=xPoint;// xthis.y=yPoint;// ythis.r=radius;//}

CircleCircleCircle

varaCircle=newCircle(5,11,99);

Circle this

Circle.prototype.pi=Math.PI;functionACirclesArea(){returnthis.pi*this.r*this.r;// ?r2}Circle.prototype.area=ACirclesArea;// CirclePrototypevara=ACircle.area();// Circle

VBScript Trim String

// trim//StringString.prototype.trim=function(){////returnthis.replace(/(^\s*)|(\s*$)/g,"");}

//vars="leadingandtrailingspaces";

// "leadingandtrailingspaces(35)"window.alert(s+"("+s.length+")");

//s=s.trim();

// "leadingandtrailingspaces(27)"window.alert(s+"("+s.length+")");

©2000MicrosoftCorporation

JScript

011*2*...1

“010”

0

“”-24-25-26

JScript

////// -1////functionfactorial(aNumber){aNumber=Math.floor(aNumber);//if(aNumber<0){// 0return-1;}if(aNumber==0){// 0 1return1;}elsereturn(aNumber*factorial(aNumber-1));//

}

©2000MicrosoftCorporation

JScript

JScript

C++“”“{}”JScript

varaCentaur="ahorsewithrider,";//aCentaur

//JScriptfunctionantiquities()// aCentaur{

//JScriptvaraCentaur="AcentaurisprobablyamountedScythianwarrior";

//JScriptaCentaur+=",misreported;thatis,";//

//JScript}//

varnothinginparticular=antiquities();aCentaur+="asseenfromadistancebyanaiveinnocent.";

/*"AcentaurisprobablyamountedScythianwarrior,

misreported;thatis,""ahorsewithrider,asseenfromadistancebyanaiveinnocent."*/

tweak();varaNumber=100;functiontweak(){varnewThing=0;// newThing

// newThing aNumbernewThing=aNumber;

// 42 aNumberaNumber=42;if(false){varaNumber;//aNumber=123;//}//

}//

JScript

varsomeVariable;

varsomeVariable="something";

JScriptJScript—var—

©2000MicrosoftCorporation

JScript

JScript

NumbersBoolean( true false)

“”

Array toString()

String newString("something")

ASCIIANSI"Zoo""aardvark"toUpperCase() toLowerCase()

IE

////functionClobber(param){////param=newObject();param.message="Thiswillnotwork";}

////functionUpdate(param){////param.message="Iwaschanged";}

//varobj=newObject();obj.message="Thisistheoriginal";

// Clobber obj.message

Clobber(obj);window.alert(obj.message);// "Thisistheoriginal"

// Update obj.messageUpdate(obj);window.alert(obj.message);// "Iwaschanged"

©2000MicrosoftCorporation

JScript

JScript01250349lengthlength514

JScript

“[]” entryNum

theListing=addressBook[entryNum];theFirstLine=theListing[1];

“.”

myObject.aProperty

“[]”

myObject["aProperty"]//

“.”“[]”

for…in

©2000MicrosoftCorporation

JScript

JScriptJScript

\b\f\n\r

\t (Ctrl-I)

\'\"\\

(\\)

document.write('TheimagepathisC:\\webstuff\\mypage\\gifs\\garden.gif.');document.write('Thecaptionreads,"Afterthesnowof\'97.Grandma\'shouseiscovered."');

©2000MicrosoftCorporation

JScript

nullJScriptCC++ Null

JScript

JScriptWebHTML<HEAD><BODY><BODY><HEAD>

IEASPWSH

JScript true

"100"==100;false==0;

“”===false

"100"===100;false===0;

theRadius=aPerimeterPoint-theCenterpoint*theCorrectionFactor;

for...in

for...in

with

with

this

this this this

IE

</SCRIPT>"</SCRIPT>""</SCR""IPT>"

IE

©2000MicrosoftCorporation

JScript

Jscript

@cc_on @if @setJscript

NetscapeNavigator

/*@cc_on@*//*@if(@_jscript_version>=4)alert("JScriptversion4orbetter");@else@*/alert("Youneedamorerecentscriptengine.");/*@end@*/

@cc_on

©2000MicrosoftCorporation

JScript

true NaN

@_win32 Win32true@_win16 Win16true@_mac AppleMacintoshtrue@_alpha DECAlphatrue@_x86 Inteltrue@_mc680x0 Motorola680x0true@_PowerPC MotorolaPowerPCtrue@_jscript true@_jscript_build Jscript@_jscript_version majorminorJscript

©2000MicrosoftCorporation

JScript

MicrosoftJScript write() writeln()document

document.write()document.writeln()

document write()HTML

document.write("Piisapproximatelyequalto"+Math.PI);document.write();

"document.write""w();"

functionw(m){//m=""+m+"";// mif("undefined"!=m){//document.write(m);}document.write("<br>");}

w('<IMGSRC="horse.gif">');w();w("Thisisanengravingofahorse.");w();

writeln() write()HTML<PRE><XMP>

write() write()

<HTML><HEAD><SCRIPTLANGUAGE="JScript">

functionsingOut(){vartheMoment=newDate();vartheHour=theMoment.getHours();vartheMinute=theMoment.getMinutes();vartheDisplacement=(theMoment.getTimezoneOffset()/60);theHour-=theDisplacement;if(theHour>23){theHour-=24}document.write(theHour+"hours,"+theMinute+"minutes,CoordinatedUniversalTime.");window.setTimeout("singOut();",60000);}</SCRIPT></HEAD><BODY><SCRIPT>singOut();</SCRIPT></BODY></HTML>window alert() document.write()

window.alert(theHour+"hours,"+theMinute+"minutes,CoordinatedUniversalTime.");window.setTimeout("singOut();",60000);}

document clear()

document.clear();

©2000MicrosoftCorporation

JScript

window window"window.alert()"

alertHTML“”

window.alert("“” ");

“--”“”“” confirm true false

vartruthBeTold=window.confirm("“”“”if(truthBeTold){window.alert(" Web ");}elsewindow.alert(" ");

“”“”"<undefined>"

alert() confirm() prompt

vartheResponse=window.prompt(" "," ");

©2000MicrosoftCorporation

JScript

JScriptJScriptECMA JScriptECMA

JScript-ECMA JScript-ECMA

©2000MicrosoftCorporation

JScript

MicrosoftJScript-ECMA/

Array,concat,join,length,reverse,slicesort(=)(OP=)

Boolean Boolean/*...*///

/

NaNnulltrue,falseInfinityundefinedBreakcontinuedo...whileforfor...inif...elseLabeledreturnswitchwhileDategetDate,getDay,getFullYear,getHours,getMilliseconds,getMinutes,getMonth,getSeconds,getTime,getTimezoneOffset,getYear,getUTCDate,getUTCDay,getUTCFullYear,getUTCHours,getUTCMilliseconds,getUTCMinutes,getUTCMonth,getUTCSeconds,setDate,setFullYear,setHours,setMilliseconds,setMinutes,setMonth,setSeconds,setTime,setYear,setUTCDate,setUTCFullYear,setUTCHours,setUTCMilliseconds,setUTCMinutes,setUTCMonth,setUTCSeconds,toGMTString,toLocaleString,toUTCString,parse,UTCFunctionnewthisvarwithError,description,number,throw,try...catchCaller,Functionarguments,length

Global

Globalescape,unescapeevalisFinite,isNaNparseInt,parseFloatMathabs,acos,asin,atan,atan2,ceil,cos,exp,floor,log,max,min,pow,

random,round,sin,sqrt,tan,E,LN2,LN10,LOG2E,LOG10E,PI,SQRT1_2,SQRT2NumberMAX_VALUE,MIN_VALUENaNNEGATIVE_INFINITY,POSITIVE_INFINITYObjectnewconstructor,prototype,toString,valueOf(+) ,(-)(%)(*) ,(/)(-)(==) ,(!=)(<) ,(<=)(>)(>=)(&&) ,(||) ,(!)(&) ,(|) ,(~) ,(^)(<<) ,(>>)(>>>)(?:)(,)delete,typeof,void(--) ,(++) ,(===) ,(!==)ArrayBooleanDateFunctionGlobalMathNumberObjectRegExpStringRegExpindex,input,lastIndex,$1...$9,source,compile,exec,testRegularExpressionSyntaxStringcharAt,charCodeAt,fromCharCodeindexOf,lastIndexOfsplittoLowerCase,toUpperCaselengthconcat,slicematch,replace,searchanchor,big,blink,bold,fixed,fontcolor,fontsize,italics,link,small,strike,sub,sup

©2000MicrosoftCorporation

JScript

MicrosoftJScript--ECMA/

VBArraydimensions,getItem,lbound,toArray,ubound@cc_on@if@set

getVarDateEnumeratoratEnd,item,moveFirst,moveNextEnumerator

VBArrayActiveXObjectGetObjectScriptEngineScriptEngineBuildVersionScriptEngineMajorVersionScriptEngineMinorVersion

©2000MicrosoftCorporation

JScript

JScript

$1...$9absacos

Automation ActiveXObject+

NAMEHTML anchorargumentsArrayasin=atan

Xy,x atan2Boolean atEndStringHTML<BIG> big

&<<~|>>^

HTML<BLINK> String blinkHTML<B> String boldBoolean Boolean

label breakcaller

try catch@cc_onceilcharAt

Unicode charCodeAt,

JScript //JScript /*..*/Boolean

compile

concatArrayString concatStringJScript

?:

constructorcontinuecosDate--deletedescriptionDictionary

VBArray dimensions/

false do...whileEuler E

Enumerator==

JScript Error String escapeJScript eval

exec e exp

FileSystemObjectHTML<TT> String fixed

floorHTMLCOLOR<FONT> String fontcolor

HTMLSIZE<FONT> String fontsize

true forfor...in

Unicode fromCharCodeFunctionfunction

Date getDate Date getDay Date getFullYear Date getHours

getItem Date getMilliseconds Date getMinutes Date getMonthAutomation GetObject Date getSeconds Date getTimeUTC getTimezoneOffsetUTC Date getUTCDateUTC Date getUTCDay

UTC Date getUTCFullYearUTC Date getUTCHoursUTC Date getUTCMillisecondsUTC Date getUTCMinutesUTC Date getUTCMonthUTC Date getUTCSeconds DateVT_DATE getVarDate Date getYear

Global>>====@ifif...else++index

String indexOf!=

Number.POSITIVE_INFINITY Infinityinput

Boolean instanceofBoolean isFiniteBoolean NaN isNaNHTML<I> String italics

item String join

LabeledlastIndex

String lastIndexOfVBArray lbound1 lengthArray

lengthFunction String lengthString

<<=

HREFHTML String link2 LN210 LN10

log2 eEuler LOG2E10eEuler LOG10E

&&!||match

Mathmax

JScript MAX_VALUEmin

JScript MIN_VALUE%moveFirstmoveNext*

NaN NaNGlobal NaN NaNNumberJScript- Number.MAX_VALUE NEGATIVE_INFINITY

new!==Numbernumber

JScript ObjectJScript197011 parse

parseFloatparseInt

3.141592653589793 PIJScript Number.MAX_VALUE POSITIVE_INFINITY

powprototype

01 randomRegExp

replacereturn

Array reverseround

JScriptScriptEngineScriptEngineBuildVersionScriptEngineMajorVersionScriptEngineMinorVersionsearch@set

Date setDate Date setFullYear Date setHours Date setMilliseconds Date setMinutes

Date setMonth Date setSeconds Date setTimeUTC Date setUTCDateUTC Date setUTCFullYearUTC Date setUTCHoursUTC Date setUTCMillisecondsUTC Date setUTCMinutesUTC Date setUTCMonthUTC Date setUTCSeconds Date setYear

sinsliceArraysliceString

HTML<SMALL> String small Array sort

sourcesplitsqrt

0.512 SQRT1_22 SQRT2HTML<STRIKE> String strike

StringHTML<SUB> String sub

substr String substring

-HTML<SUP> String sup

switchJScript

tanBoolean test

this try...catch throwVBArrayJScript toArrayGMT toGMTString

toLocaleStringtoLowerCasetoStringtoUpperCase

UTC toUTCStringJScript try

typeofVBArray ubound

-

escape String unescape>>>

197011UTCGMT UTCvalueOfvar

VisualBasic VBArrayvoid

false whilewith

©2000MicrosoftCorporation

JScript

JScript

JScript

JScript

©2000MicrosoftCorporation

JScript

JScript

JScriptJScriptJScript

50295030

5028 Arrayarguments

5010 Boolean50035000 'this'5006 Date5015 Enumerator50225020 “)”5019 “]”5023 Prototype5002 Function500850215014 JScript5001 Number5007 Object501250165005 String5017502650275025 URI5024 URI500950185013 VBArray

JScript

©2000MicrosoftCorporation

JScript

JScript

JScriptJScriptJScriptJScript

1019 “break”1020 “continue”1030

1027 “switch”“default”

1005 “(”1006 “)”1012 “/”1003 “:”1004 “;”1032 “@”1029 “@end”1007 “]”1008 “{”1009 “}”1011 “=”1033 “catch”10311023101010281024 “while”1014102610251018 'return'10021035 “Throw”10161015

JScript

©2000MicrosoftCorporation

JScript

JScript

Automation GetObjectScriptEngineScriptEngineBuildVersion

ScriptEngineMajorVersion

ScriptEngineMinorVersion

©2000MicrosoftCorporation

JScript

GetObject

Automation

GetObject([pathname][,class])

pathname pathname class

class

appname.objectype

appname

objectype

GetObjectAutomation GetObject

varCADObject;CADObject=GetObject("C:\\CAD\\SCHEMA.CAD"); pathname pathname("") GetObjectpathname GetObject

(!)

SCHEMA.CAD

varLayerObject=GetObject("C:\\CAD\\SCHEMA.CAD!Layer3"Automation class

varMyObject;MyObject=GetObject("C:\\DRAWINGS\\SAMPLE.DRW","FIGMENT.DRAWING"

FIGMENTDRAWINGMyObject

MyObject.Line(9,90);MyObject.InsertText(9,100,"Hello,world.");MyObject.SaveAs("C:\\DRAWINGS\\SAMPLE.DRW");

GetObject ActiveXObject

ActiveXObject GetObject("") pathname

5

ActiveXObject

©2000MicrosoftCorporation

JScript

ScriptEngine

ScriptEngine()

ScriptEngine

JScript MicrosoftJScriptScriptingVBA MicrosoftVisualBasicforApplicationsScriptingVBScript MicrosoftVisualBasicScriptingEditionScripting

ScriptEngine

functionGetScriptEngineInfo(){vars;s="";//s+=ScriptEngine()+"Version";s+=ScriptEngineMajorVersion()+".";s+=ScriptEngineMinorVersion()+".";s+=ScriptEngineBuildVersion();return(s);}

5

ScriptEngineBuildVersion|ScriptEngineMajorVersion|ScriptEngineMinorVersion

©2000MicrosoftCorporation

JScript

ScriptEngineBuildVersion

Scripting

ScriptEngineBuildVersion()

Scripting(DLL)

ScriptEngineBuildVersion

functionGetScriptEngineInfo(){vars;s="";//s+=ScriptEngine()+"Version";s+=ScriptEngineMajorVersion()+".";s+=ScriptEngineMinorVersion()+".";s+=ScriptEngineBuildVersion();return(s);}

5

ScriptEngine|ScriptEngineMajorVersion|ScriptEngineMinorVersion

©2000MicrosoftCorporation

JScript

ScriptEngineMajorVersion

Scripting

ScriptEngineMajorVersion()

Scripting(DLL)

ScriptEngineMajorVersion

functionGetScriptEngineInfo(){vars;s="";//s+=ScriptEngine()+"Version";s+=ScriptEngineMajorVersion()+".";s+=ScriptEngineMinorVersion()+".";s+=ScriptEngineBuildVersion();return(s);}

5

ScriptEngine|ScriptEngineBuildVersion|ScriptEngineMinorVersion

©2000MicrosoftCorporation

JScript

ScriptEngineMinorVersion

Scripting

ScriptEngineMinorVersion()

Scripting(DLL)

ScriptEngineMinorVersion

functionGetScriptEngineInfo(){vars;s="";//s+=ScriptEngine()+"Version";s+=ScriptEngineMajorVersion()+".";s+=ScriptEngineMinorVersion()+".";s+=ScriptEngineBuildVersion();return(s);}

5

ScriptEngine|ScriptEngineBuildVersion|ScriptEngineMajorVersion

©2000MicrosoftCorporation

JScript

JScript

absacos

NAMEHTML anchorasinatan

Xy,x atan2Boolean atEndStringHTML<BIG> bigHTML<BLINK> String blinkHTML<B> String bold

ceilcharAt

Unicode charCodeAtcompileconcatArray

String concatStringcos

VBArray dimensions String escapeJScript eval

exece expHTML<TT> String fixed

floorHTMLCOLOR<FONT> String fontcolor

HTMLSIZE<FONT> String fontsize

Unicode fromCharCode Date getDate Date getDay Date getFullYear Date getHours

getItem Date getMilliseconds Date getMinutes Date getMonth Date getSeconds Date getTimeUTC getTimezoneOffsetUTC Date getUTCDate

UTC Date getUTCDayUTC Date getUTCFullYearUTC Date getUTCHoursUTC Date getUTCMillisecondsUTC Date getUTCMinutesUTC Date getUTCMonthUTC Date getUTCSeconds DateVT_DATE getVarDate Date getYear String indexOfBoolean isFiniteBoolean NaN isNaNHTML<I> String italics

item String join String lastIndexOfVBArray lboundHREFHTML String link

logmatchmaxminmoveFirstmoveNext

197011 parseparseFloatparseIntpow

01 randomreplace

Array reverseroundsearch

Date setDate Date setFullYear Date setHours Date setMilliseconds Date setMinutes Date setMonth Date setSeconds Date setTimeUTC Date setUTCDateUTC Date setUTCFullYearUTC Date setUTCHoursUTC Date setUTCMilliseconds

UTC Date setUTCMinutesUTC Date setUTCMonthUTC Date setUTCSeconds Date setYear

sinsliceArraysliceString

HTML<SMALL> String small Array sort

splitsqrt

HTML<STRIKE> String strikeHTML<SUB> String sub

substr String substringHTML<SUP> String sup

tanBoolean testVBArrayJScript toArrayGMT toGMTString

toLocaleStringtoLowerCasetoStringtoUpperCase

UTC toUTCStringVBArray uboundescape String unescape197011UTCGMT UTC

valueOf

©2000MicrosoftCorporation

JScript

abs

Math.abs(number)

number

number

abs

functionComparePosNegVal(n){vars;varv1=Math.abs(n);varv2=Math.abs(-n);if(v1==v2)s=n+""s+=-n+" ";return(s);}

1

Math

Math

©2000MicrosoftCorporation

JScript

acos

Math.acos(number)

number

number

1

asin|atan|cos|sin|tan

Math

©2000MicrosoftCorporation

JScript

anchor

NAMEHTML

strVariable.anchor(anchorString)

strVariable String

anchorStringHTMLNAME

anchor String anchor

varstrVariable="Thisisananchor";strVariable=strVariable.anchor("Anchor1"); strVariable

<ANAME="Anchor1">Thisisananchor</A>

1

link|String|String

String

©2000MicrosoftCorporation

JScript

apply

apply([thisObj[,argArray]])

thisObj

argArray

argArray argumentsTypeError

argArray thisObj Global thisObj

5.5

Function

©2000MicrosoftCorporation

JScript

asin

Math.asin(number)

number

1

acos|atan|cos|Math|sin|tan

Math

©2000MicrosoftCorporation

JScript

atan

Math.atan(number)

number

1

acos|asin|atan2|cos|Math|sin|tan

Math

©2000MicrosoftCorporation

JScript

atan2

X( y,x)

Math.atan2(y,x)

xx

yy

-pi pi( y,x)

1

atan|tan

Math

©2000MicrosoftCorporation

JScript

atEnd

Boolean

myEnum.atEnd()

myEnum Enumerator

, atEnd true false

atEnd

functionShowDriveList(){varfso,s,n,e,x;fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);s="";for(;!e.atEnd();e.moveNext()){x=e.item();s=s+x.DriveLetter;s+="-";if(x.DriveType==3)n=x.ShareName;elseif(x.IsReady)n=x.VolumeName;else

n="[ ]";s+=n+"<br>";}return(s);}

2

item|moveFirst|moveNext

Enumerator

©2000MicrosoftCorporation

JScript

big

HTML<BIG> String

strVariable.big()

strVariable String

big

varstrVariable="Thisisastringobject";strVariable=strVariable.big();

strVariable

<BIG>Thisisastringobject</BIG>

1

small|String|String

String

©2000MicrosoftCorporation

JScript

blink

HTML<BLINK> String

strVariable.blink()

strVariable String

blink

varstrVariable="Thisisastringobject";strVariable=strVariable.blink();

strVariable

<BLINK>Thisisastringobject</BLINK>

MicrosoftInternetExplorer<BLINK>

1

String|String

String

©2000MicrosoftCorporation

JScript

bold

HTML<B> String

strVariable.bold()

strVariable String

bold

varstrVariable="Thisisastringobject";strVariable=strVariable.bold();

strVariable

<B>Thisisastringobject</B>

1

italics|String|String

String

©2000MicrosoftCorporation

JScript

call

call([thisObj[,arg1[,arg2[,[,.argN]]]]])

thisObj

arg1,arg2,,argN

call call thisObj

thisObj Global thisObj

5.5

Function

©2000MicrosoftCorporation

JScript

ceil

Math.ceil(number)

number

1

floor|Math

Math

©2000MicrosoftCorporation

JScript

charAt

strObj.charAt(index)

strObj String

index01

charAt01

charAt

functioncharAtTest(n){varstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ";//vars;//s=str.charAt(n-1);// n–1//return(s);//}

1

String|String

String

©2000MicrosoftCorporation

JScript

charCodeAt

Unicode

strObj.charCodeAt(index)

strObj String

index01

01

NaN

charCodeAt

functioncharCodeAtTest(n){varstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ";//varn;//n=str.charCodeAt(n-1);// n Unicodereturn(n);//}

5.5

fromCharCode|String

String

©2000MicrosoftCorporation

JScript

compile

rgExp.compile(pattern,[flags])

rgexp

pattern

flags

g( pattern)

i()

m()

compile pattern

compile

functionCompileDemo(){varrs;vars="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPp"//

varr=newRegExp("[A-Z]","g");vara1=s.match(r)////r.compile("[a-z]","g");vara2=s.match(r)//return(a1+"\n"+a2;}

3

||

©2000MicrosoftCorporation

JScript

concat(Array)

array1.concat([item1[,item2[,...[,itemN]]]])

array1 Array

item1,...,itemN array1

concat Array array1

item1…itemN array1

concat:

functionConcatArrayDemo(){vara,b,c,d;a=newArray(1,2,3);b="JScript";c=newArray(42,"VBScript);

d=a.concat(b,c);// [1,2,3,"JScript",42,"VBScript"]return(d);}

3

concat(String) |join|String

Array

©2000MicrosoftCorporation

JScript

concatString

string1.concat([string2[,string3[,...[,stringN]]]])

string1 String

string2,...,stringN string1 String

concat result=string1+string2+string3+…+stringN string1

concat

functionconcatDemo(){varstr1="ABCDEFGHIJKLM"varstr2="NOPQRSTUVWXYZ";vars=str1.concat(str2);//return(s);}

3

(+)|Array|concatArray |String

String

©2000MicrosoftCorporation

JScript

cos

Math.cos(number)

number

1

acos|asin|atan|Math|sin|tan

Math

©2000MicrosoftCorporation

JScript

decodeURI

(URI)

decodeURI(URIstring)

URIstringURI

decodeURI unescape

decodeURI

URIStringURIError

5.5

decodeURIComponent|encodeURI

Global

©2000MicrosoftCorporation

JScript

decodeURIComponent

(URI)

decodeURIComponent(encodedURIString)

encodedURIStringURI

URIComponentURI

encodedURIStringURIError

5.5

decodeURI|encodeURI

Global

©2000MicrosoftCorporation

JScript

dimensions

VBArray

array.dimensions()

array VBArray

dimensionsVBArray

VisualBasicVBScriptJScriptHTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1Fori=0To2Forj=0To2a(j,i)=kk=k+1NextNextCreateVBArray=aEndFunction-->

</SCRIPT>

<SCRIPTLANGUAGE="JScript"><!--functionVBArrayTest(vba){vari,s;vara=newVBArray(vba);for(i=1;i<=a.dimensions();i++){s="Theupperboundofdimension";s+=i+"is";s+=a.ubound(i)+".<BR>";}return(s);}--></SCRIPT></HEAD>

<BODY><SCRIPTlanguage="jscript">document.write(VBArrayTest(CreateVBArray()));</SCRIPT></BODY>

3

getItem|lbound|toArray|ubound

VBArray

©2000MicrosoftCorporation

JScript

encodeURI

(URI)

encodeURI(URIString)

URIStringURI

encodeURIURI decodeURI encodeURI":""/"";""?"encodeURIComponent

5.5

decodeURI|decodeURIComponent

Global

©2000MicrosoftCorporation

JScript

encodeURIComponent

(URI)

encodeURIComponent(encodedURIString)

encodedURIStringURI

encodeURIComponentURI decodeURIComponentencodeURIComponent /folder1/folder2/default.htmlwebURI encodeURI

5.5

decodeURI|decodeURIComponent

Global

©2000MicrosoftCorporation

JScript

escape

String

escape(charString)

charstring String

escape charstringUnicode ASCII %xxxx"%20"

255 %uxxxx

escape(URI) encodeURIencodeURIComponent

1

encodeURI|encodeURIComponent|String|unescape

Global

©2000MicrosoftCorporation

JScript

eval

JScript.

eval(codeString)

codestring JScriptJScript

evalJScript, Date mydate

eval("varmydate=newDate();"); eval eval.

1

String

Global

©2000MicrosoftCorporation

JScript

exec

rgExp.exec(str)

rgExp

str String

exec null exec RegExp01n(g)match

exec lastIndex exec lastIndex

exec inputindex lastIndexInput Index LastIndex

exec

functionRegExpTest(){varver=Number(ScriptEngineMajorVersion()+"."+ScriptEngineMinorVersion())if(ver>=5.5){// JScriptvarsrc="TheraininSpainfallsmainlyintheplain.";varre=/\w+/g;//vararr;

while((arr=re.exec(src))!=null)document.write(arr.index+"-"+arr.lastIndex+"\t"+arr);}else{alert(" JScript ");}}

3

match|RegExp||||search|test

©2000MicrosoftCorporation

JScript

exp

e

Math.exp(number)

number e

enumber e2.178 number

1

E|Math

Math

©2000MicrosoftCorporation

JScript

fixed

HTML<TT> String

strVariable.fixed()

strVariable String

fixed

varstrVariable="Thisisastringobject";strVariable=strVariable.fixed();

strVariable

<TT>Thisisastringobject</TT>

1

String|String

String

©2000MicrosoftCorporation

JScript

floor

Math.floor(number)

number

1

ceil|Math

Math

©2000MicrosoftCorporation

JScript

fontcolor

COLORHTML<FONT> String

strVariable.fontcolor(colorVal)

strVariable String

colorVal

fontcolor

varstrVariable="Thisisastring";strVariable=strVariable.fontcolor("red");

strVariable

<FONTCOLOR="RED">Thisisastring</FONT>

JScript

1

fontsize|String|String

String

©2000MicrosoftCorporation

JScript

fontsize

SIZEHTML<FONT> String

strVariable.fontsize(intSize)

strVariable String

intSize

fontsize

varstrVariable="Thisisastring";strVariable=strVariable.fontsize(-1);

strVariable

<FONTSIZE="-1">Thisisastring</FONT>

MicrosoftJScript

1

fontcolor|String|String

String

©2000MicrosoftCorporation

JScript

fromCharCode

Unicode

String.fromCharCode([code1[,code2[,...[,codeN]]]])

String String

code1,...,codeNUnicode

fromCharCode String

test"plain"

vartest=String.fromCharCode(112,108,97,105,110);

3

charCodeAt|String

String

©2000MicrosoftCorporation

JScript

getDate

Date

dateObj.getDate()

dateObj Date

(UTC) getUTCDate

131 Date

getDate

functionDateDemo(){vard,s=" :";d=newDate();s+=(d.getMonth()+1)+"/";s+=d.getDate()+"/";s+=d.getYear();return(s);}

1

Date|getUTCDate|setDate|setUTCDate

Date

©2000MicrosoftCorporation

JScript

getDay

Date

dateObj.getDay()

dateObj Date

(UTC) getUTCDay

getDay06

0123456

getDay

functionDateDemo(){vard,day,x,s=" :";varx=newArray(" "," "," ");varx=x.concat(" "," "," ");varx=x.concat(" ");d=newDate();day=d.getDay();return(s+=x[day]);}

1

Date|getUTCDay

Date

©2000MicrosoftCorporation

JScript

getFullYear

Date

dateObj.getFullYear()

dateObj Date

(UTC) getUTCFullYear

getFullYear197619762000200011190011

GetFullYear

functionDateDemo(){vard,s=" UTC :";d=newDate();s+=(d.getMonth()+1)+"/";s+=d.getDate()+"/";s+=d.getFullYear();return(s);}

3

Date|getUTCFullYear|setFullYear|setUTCFullYear

Date

©2000MicrosoftCorporation

JScript

getHours

Date

dateObj.getHours()

dateObj Date

(UTC) getUTCHours

getHours02301:00:00am Date00 Date

getHours

functionTimeDemo(){vard,s=" :";varc=":";d=newDate();s+=d.getHours()+c;s+=d.getMinutes()+c;s+=d.getSeconds()+c;s+=d.getMilliseconds();return(s);}

1

Date|getUTCHours|setHours|setUTCHours

Date

©2000MicrosoftCorporation

JScript

getItem

safeArray.getItem(dimension1[,dimension2,...],dimensionN)

safeArray VBArray

dimension1,...,dimensionNVBArray nVBArray

VisualBasicVBScriptJScriptHTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1Fori=0To2Forj=0To2a(i,j)=kdocument.writeln(k)k=k+1

Nextdocument.writeln("<BR>")NextCreateVBArray=aEndFunction--></SCRIPT><SCRIPTLANGUAGE="JScript"><!--functionGetItemTest(vbarray){vari,j;vara=newVBArray(vbarray);for(i=0;i<=2;i++){for(j=0;j<=2;j++){document.writeln(a.getItem(i,j));}}}--></SCRIPT></HEAD>&ltBODY><SCRIPTLANGUAGE="JScript"><!--GetItemTest(CreateVBArray());-->

</SCRIPT></BODY>

1

dimensions|lbound|toArray|ubound

VBArray

©2000MicrosoftCorporation

JScript

getMilliseconds

Date

dateObj.getMilliseconds()

dateObj Date

(UTC) getUTCMilliseconds

0-999

getMilliseconds

functionTimeDemo(){vard,s=" :";varc=":";d=newDate();s+=d.getHours()+c;s+=d.getMinutes()+c;s+=d.getSeconds()+c;s+=d.getMilliseconds();return(s);}

3

Date|getUTCMilliseconds|setMilliseconds|setUTCMilliseconds

Date|getUTCMilliseconds|setMilliseconds|setUTCMilliseconds

©2000MicrosoftCorporation

JScript

getMinutes

Date

dateObj.getMinutes()

dateObj Date

(UTC) getUTCMinutes

getMinutes059 Date0 Date00 Date

getMinutes

functionTimeDemo(){vard,s=" :";varc=":";d=newDate();s+=d.getHours()+c;s+=d.getMinutes()+c;s+=d.getSeconds()+c;s+=d.getMilliseconds();return(s);}

3

Date|getUTCMinutes|setMinutes|setUTCMinutes

Date

©2000MicrosoftCorporation

JScript

getMonth

Date

dateObj.getMonth()

dateObj Date

(UTC) getUTCMonth

getMonth011 Date1 Date"Jan5,199608:47:00" getMonth0

getMonth

functionDateDemo(){vard,s=" :";d=newDate();s+=(d.getMonth()+1)+"/";s+=d.getDate()+"/";s+=d.getYear();return(s);}

1

Date|getUTCMonth|setMonth|setUTCMonth

Date

©2000MicrosoftCorporation

JScript

getSeconds

Date

dateObj.getSeconds()

dateObj Date

(UTC) getUTCSeconds

getSeconds059 Date0 Date00 Date

getSeconds

functionTimeDemo(){vard,s=" :";varc=":";d=newDate();s+=d.getHours()+c;s+=d.getMinutes()+c;s+=d.getSeconds()+c;s+=d.getMilliseconds();return(s);}

1

Date|getUTCSeconds|setSeconds|setUTCSeconds

Date

©2000MicrosoftCorporation

JScript

getTime

Date

dateObj.getTime()

dateObj Date

getTime197011 Date197011285,6161970

varMinMilli=1000*60varHrMilli=MinMilli*60varDyMilli=HrMilli*24

getTime

functionGetTimeTest(){vard,s,t;varMinMilli=1000*60;varHrMilli=MinMilli*60;varDyMilli=HrMilli*24;d=newDate();t=d.getTime();s="It'sbeen"s+=Math.round(t/DyMilli)+"dayssince1/1/70";

return(s);}

1

Date|setTime

Date

©2000MicrosoftCorporation

JScript

getTimezoneOffset

(UTC)

dateObj.getTimezoneOffset()

dateObj Date

getTimezoneOffsetUTC

UTC(PacificDaylightTime)UTC(Japan)

121LosAngelesNewYorkCitygetTimezoneOffset480300

getTimezoneOffset

functionTZDemo(){vard,tz,s="Thecurrentlocaltimeis";d=newDate();tz=d.getTimezoneOffset();if(tz<0)s+=tz/60+"hoursbeforeGMT";elseif(tz==0)s+="GMT";elses+=tz/60+"hoursafterGMT";return(s);

}

1

Date

Date

©2000MicrosoftCorporation

JScript

getUTCDate

Date(UTC)

dateObj.getUTCDate()

dateObj Date

getDate

131 Date

getUTCDate

functionUTCDateDemo(){vard,s=" UTC :";d=newDate();s+=(d.getUTCMonth()+1)+"/";s+=d.getUTCDate()+"/";s+=d.getUTCFullYear();return(s);}

3

Date|getDate|setDate|setUTCDate

Date

©2000MicrosoftCorporation

JScript

getUTCDay

Date(UTC)

dateObj.getUTCDay()

dateObj Date

getDate

getUTCDay06

0123456

getUTCDay

functionDateDemo(){vard,day,x,s=" ";varx=newArray(" "," "," ");x=x.concat(" "," "," ");x=x.concat(" ");d=newDate();day=d.getUTCDay();return(s+=x[day]);

}

3

Date|getDay

Date

©2000MicrosoftCorporation

JScript

getUTCFullYear

Date(UTC)

dateObj.getUTCFullYear()

dateObj Date

getFullYear

getUTCFullYear2000200011190011

getUTCFullYear

functionUTCDateDemo(){vard,s=" UTC :";d=newDate();s+=(d.getUTCMonth()+1)+"/";s+=d.getUTCDate()+"/";s+=d.getUTCFullYear();return(s);}

3

Date|getFullYear|setFullYear|setUTCFullYear

Date

©2000MicrosoftCorporation

JScript

getUTCHours

Date(UTC)

dateObj.getUTCHours()

dateObj Date

getHours

getUTCHours02301:00:00A.M. Date00 Date

getUTCHours

functionUTCTimeDemo(){vard,s=" (UTC):";varc=":";d=newDate();s+=d.getUTCHours()+c;s+=d.getUTCMinutes()+c;s+=d.getUTCSeconds()+c;s+=d.getUTCMilliseconds();return(s);}

3

Date|getHours|setHours|setUTCHours

Date

©2000MicrosoftCorporation

JScript

getUTCMilliseconds

Date(UTC)

dateObj.getUTCMilliseconds()

dateObj Date

getMilliseconds

0-999

getUTCMilliseconds

functionUTCTimeDemo(){vard,s=" (UTC):";varc=":";d=newDate();s+=d.getUTCHours()+c;s+=d.getUTCMinutes()+c;s+=d.getUTCSeconds()+c;s+=d.getUTCMilliseconds();return(s);}

3

Date|getMilliseconds|setMilliseconds|setUTCMilliseconds

Date

©2000MicrosoftCorporation

JScript

getUTCMinutes

Date(UTC)

dateObj.getUTCMinutes()

dateObj Date

getMinutes

getUTCMinutes059 Date01 Date00

getUTCMinutes

functionUTCTimeDemo(){vard,s=" (UTC):";varc=":";d=newDate();s+=d.getUTCHours()+c;s+=d.getUTCMinutes()+c;s+=d.getUTCSeconds()+c;s+=d.getUTCMilliseconds();return(s);}

3

Date|getMinutes|setMinutes|setUTCMinutes

Date

©2000MicrosoftCorporation

JScript

getUTCMonth

Date(UTC)

dateObj.getUTCMonth()

dateObj Date

getMonth

getUTCMonth011Date1 Date"Jan5,199608:47:00.0" getUTCMonth0

getUTCMonth

functionUTCDateDemo(){vard,s=" UTC :";d=newDate();s+=(d.getUTCMonth()+1)+"/";s+=d.getUTCDate()+"/";s+=d.getUTCFullYear();return(s);}

3

Date|getMonth|setMonth|setUTCMonth

Date

©2000MicrosoftCorporation

JScript

getUTCSeconds

Date(UTC)

dateObj.getUTCSeconds()

dateObj Date

getSeconds

getUTCSeconds059 Date01 Date00

getUTCSeconds

functionUTCTimeDemo(){vard,s=" UTC :";varc=":";d=newDate();s+=d.getUTCHours()+c;s+=d.getUTCMinutes()+c;s+=d.getUTCSeconds()+c;s+=d.getUTCMilliseconds();return(s);}

3

Date|getSeconds|setSeconds|setUTCSeconds

Date

©2000MicrosoftCorporation

JScript

getVarDate

DateVT_DATE

dateObj.getVarDate()

dateObj Date

COMActiveX(R)VT_DATEVisualBasicVBScriptgetVarDateJScript

3

getDate|parse

Date

©2000MicrosoftCorporation

JScript

getYear

Date

dateObj.getYear()

dateObj Date

getFullYear

1900-199919001996961825202518252025

JScript1.0 getYear Date19001899-12000100

getYear

functionDateDemo(){vard,s=" :";d=newDate();s+=(d.getMonth()+1)+"/";s+=d.getDate()+"/";s+=d.getYear();return(s);}

1

Date|getFullYear|getUTCFullYear|setFullYear|setUTCFullYear|setYear

Date

©2000MicrosoftCorporation

JScript

indexOf

String

strObj.indexOf(subString[,startIndex])

strObjString

subString String

starIndex String

indexOf String-1

startindex startindex

lastIndexOf

indexOf

functionIndexDemo(str2){varstr1="BABEBIBOBUBABEBIBOBU"vars=str1.indexOf(str2);return(s);

}

1

lastIndexOf|String|String

String

©2000MicrosoftCorporation

JScript

isFinite

Boolean,

isFinite(number)

number

number NaN isFinite true false

3

isNaN

Global

©2000MicrosoftCorporation

JScript

isNaN

Boolean NaN

isNaN(numValue)

numvalue NAN

NaN isNaN true false parseInt parseFloat

NaN NaN

1

isFinite|NaN(Global) |parseFloat|parseInt

Global

©2000MicrosoftCorporation

JScript

italics

HTML<I> String

strVariable.italics()"StringLiteral".italics()

italics

varstrVariable="Thisisastring";strVariable=strVariable.italics();

strVariable

<I>Thisisastring</I>

1

bold|String|String

String

©2000MicrosoftCorporation

JScript

item

enumObj.item()

myEnum Enumerator

item undefined

item Drives

functionShowDriveList(){varfso,s,n,e,x;fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);s="";for(;!e.atEnd();e.moveNext()){x=e.item();s=s+x.DriveLetter;s+="-";if(x.DriveType==3)n=x.ShareName;elseif(x.IsReady)n=x.VolumeName;else

n="[ ]";s+=n+"<br>";}return(s);}

3

atEnd|moveFirst|moveNext

Enumerator

©2000MicrosoftCorporation

JScript

join

arrayObj.join(separator)

arrayObjArray

separator String String

null

join

functionJoinDemo(){vara,b;a=newArray(0,1,2,3,4);b=a.join("-");return(b);}

2

Array|String

Array

©2000MicrosoftCorporation

JScript

lastIndexOf

String

strObj.lastIndexOf(substring[,startindex])

strObjString

substring String

startindex String

lastIndexOf String-1

startindex startindex

indexOf

lastIndexOf

functionlastIndexDemo(str2){varstr1="BABEBIBOBUBABEBIBOBU"vars=str1.lastIndexOf(str2);return(s);}

1

indexOf|String|String

String

©2000MicrosoftCorporation

JScript

lbound

VBArray

safeArray.lbound(dimension)

safeArray VBArray

dimensionVBArray lbound1

VBArray lbound undefined dimensionVBArray“”

VisualBasicVBScriptJScriptVBScriptVisualBasic0HTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1

Fori=0To2Forj=0To2a(j,i)=kk=k+1NextNextCreateVBArray=aEndFunction--></SCRIPT>

<SCRIPTLANGUAGE="JScript">

<!--

functionVBArrayTest(vba)

{

vari,s;vara=newVBArray(vba);for(i=1;i<=a.dimensions();i++){s="Thelowerboundofdimension";s+=i+"is";s+=a.lbound(i)+".<BR>";return(s);}

}

-->

</SCRIPT>

</HEAD>

<BODY>

<SCRIPTlanguage="jscript">

document.write(VBArrayTest(CreateVBArray()));

</SCRIPT>

</BODY>

3

dimensions|getItem|toArray|ubound

VBArray

©2000MicrosoftCorporation

JScript

link

HREFHTML String

strVariable.link(linkstring)"StringLiteral".link(linkstring)

linkstringHTMLHREF

link String

varstrVariable="Thisisahyperlink";strVariable=strVariable.link("http://www.microsoft.com"

strVariable

<ahref="http://www.microsoft.com">Thisisahyperlink</A>

1

anchor|String|String

String

©2000MicrosoftCorporation

JScript

localeCompare

stringVar.localeCompare(stringExp)

stringVar String

stringExp stringVar

localeCompare stringVar stringExp–10+1

stringVar stringExp localeCompare–1 stringVarstringExp+10

5.5

toLocalString

String

©2000MicrosoftCorporation

JScript

log

Math.log(number)

number

number e

1

Math

Math

©2000MicrosoftCorporation

JScript

match

stringObj.match(rgExp)

stringObj String

rgExp

match null RegExp

match inputindexlastIndexInput Index LastIndex

(g)01n exec0n

match

functionMatchDemo(){varr,re;//vars="TheraininSpainfallsmainlyintheplain";re=/ain/i;//r=s.match(re);//return(r);// "ain"}

gmatch

functionMatchDemo(){varr,re;//vars="TheraininSpainfallsmainlyintheplain";re=/ain/ig;//r=s.match(re);//return(r);// "ain"//}

match

varr,re="Spain";r="TheraininSpain".replace(re,"Canada");

3

exec|RegExp|replace|search|String|test

String

©2000MicrosoftCorporation

JScript

max

Math.max([number1[,number2[...[,numberN]]]])

number1,number2,...,numberN

NEGATIVE_INFINITY NaN NaN

1

Math|min|NEGATIVE_INFINITY

Math

©2000MicrosoftCorporation

JScript

min

Math.min([number1[,number2[...[,numberN]]]])

number1,number2,...,numberN

POSITIVE_INFINITY NaN NaN

1

Math|max|POSITIVE_INFINITY

Math

©2000MicrosoftCorporation

JScript

moveFirst

enumObj.moveFirst()

enumObj Enumerator

undefined

moveFirst Drives

functionShowFirstAvailableDrive(){varfso,s,e,x;//fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);// Enumeratore.moveFirst();//s="";// sdo{x=e.item();//if(x.IsReady)//{s=x.DriveLetter+":";// sbreak;}else

if(e.atEnd())//{s=" ";break;}e.moveNext();//}while(!e.atEnd());//return(s);//}

3

atEnd|item|moveNext

Enumerator

©2000MicrosoftCorporation

JScript

moveNext

enumObj.moveNext()

myEnum Enumerator

undefined

moveNext Drives

functionShowDriveList(){varfso,s,n,e,x;//fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);// Enumerators="";// sfor(;!e.atEnd();e.moveNext()){x=e.item();s=s+x.DriveLetter;//s+="-";//"-"if(x.DriveType==3)n=x.ShareName;//elseif(x.IsReady)n=x.VolumeName;//elsen="[ ]";//s+=n+"\n";

}return(s);//}

3

atEnd|item|moveFirst

Enumerator

©2000MicrosoftCorporation

JScript

parse

197011

Date.parse(dateVal)

dateVal"Jan5,199608:47:00"ActiveX(R)VT_DATE

parse dateVal197011

parse Date Date

vardatestring="November1,199710:15AM";Date.parse(datestring)

parse

“/”“-”//"7/20/96"

"July101995"24270

"Ju"

1996119"TuesdayNovember91996" Date"FridayNovember91996"

JScript(UTC)(GMT)

"10:""10:11""10:11:12"

2412"PM""23:15PM"

parse

functionGetTimeTest(testdate){vars,t;//varMinMilli=1000*60;//varHrMilli=MinMilli*60;varDyMilli=HrMilli*24;t=Date.parse(testdate);// testdates="Thereare"//s+=Math.round(Math.abs(t/DyMilli))+"days"s+="between"+testdate+"and1/1/70";return(s);//}

1

Date

Date

©2000MicrosoftCorporation

JScript

parseFloat

parseFloat(numString)

numString

parseFloat numString numString NaN

parseFloat("abc")// NaNparseFloat("1.2abc")// 1.2

isNaN NaN

1

isNaN|parseInt|String

Global

©2000MicrosoftCorporation

JScript

parseInt

parseInt(numString,[radix])

numString

radix236 numString'0x''0'

parseInt numString numString NaN

parseInt("abc")// NaNparseInt("12abc")// 12

isNaN NaN

1

isNaN|parseFloat|String|valueOf

Global

©2000MicrosoftCorporation

JScript

pop

arrayObj.pop()

arrayObj Array

undefined

5.5

push

Array

©2000MicrosoftCorporation

JScript

pow

Math.pow(base,exponent)

base

exponent

baseexponent1000

Math.pow(10,3);

1

Math

Math

©2000MicrosoftCorporation

JScript

push

arrayObj.push([item1[item2[...[itemN]]]])

arrayObj Array

item,item2,...itemN Array

push concat

5.5

concat|pop

Array

©2000MicrosoftCorporation

JScript

random

01

Math.random()

010101JScript

1

Math

Math

©2000MicrosoftCorporation

JScript

replace

stringObj.replace(rgExp,replaceText)

stringObj String replace

rgExp String rgExp

replaceTextString stringObj rgExpJscript5.5 replaceText

replace stringObj

$$ $JScript5.5$& stringObjJScript5.5

$` $& stringObjJScript5.5

$' $& stringObjJScript5.5

$n n n19JScript5.5

$nn nn nn0199JScript5.5

replaceTextm+3m rgExp mm+2 stringObj m+3 stringObj

Replace RegExp

replace"The""A"

functionReplaceDemo(){varr,re;//varss="Themanhittheballwiththebat.\n";ss+="whilethefieldercaughttheballwiththeglove.";re=/The/g;//r=ss.replace(re,"A");//"A" "The"return(r);//}

, replace

functionReplaceDemo(){varr,re;//varss="TheraininSpainfallsmainlyintheplain.";re=/(\S+)(\s+)(\S+)/g;//r=ss.replace(re,"$3$2$1");//return(r);//}

JScript5.5 replaceText"F""Waterboilsat212"

functionf2c(s){vartest=/(\d+(\.\d*)?)F\b/g;//return(s.replace(test,

function($0,$1,$2){return((($1-32)*5/9)+"C");}));}document.write(f2c("Waterfreezesat32Fandboilsat212F."));

1

exec|match|RegExp|search|String|test

String

©2000MicrosoftCorporation

JScript

reverse

Array

arrayObj.reverse()

arrayObj Array

reverse Array Array

reverse undefined

reverse

functionReverseDemo(){vara,l;//a=newArray(0,1,2,3,4);//l=a.reverse();//return(l);//}

2

Array

Array

©2000MicrosoftCorporation

JScript

round

Math.round(number)

number

number0.5 number round number

1

Math

Math

©2000MicrosoftCorporation

JScript

search

stringObj.search(rgExp)

stringObj String

rgExp

search search-1

search

functionSearchDemo(){varr,re;//vars="TheraininSpainfallsmainlyintheplain.";re=/falls/i;//r=s.search(re);//return(r);// Boolean}

3

exec|match|||replace|String|test

String

©2000MicrosoftCorporation

JScript

setDate

Date

dateObj.setDate(numDate)

dateObj Date

numDate

(UTC) setUTCDate

numDate Date numDate199615setUTCDate(32)199621

setDate

functionSetDateDemo(newdate){vard,s;//d=newDate();// dated.setDate(newdate);// datenewdates="Currentsettingis";s+=d.toLocaleString();return(s);//}

3

Date|getDate|getUTCDate|setUTCDate

Date

©2000MicrosoftCorporation

JScript

setFullYear

Date

dateObj.setFullYear(numYear[,numMonth[,numDate]])

dateObj Date

numYear

numMonth numDate

numDate

set get numMonthJScript getMonth

(UTC) setUTCFullYear

Date1970285,616

setFullYear

functionSetFullYearDemo(newyear){

vard,s;//d=newDate();// Dated.setFullYear(newyear);//s="Currentsettingis";s+=d.toLocaleString();return(s);//}

3

Date|getFullYear|getUTCFullYear|setUTCFullYear

Date

©2000MicrosoftCorporation

JScript

setHours

Date

dateObj.setHours(numHours[,numMin[,numSec[,numMilli]]])

dateObj Date

numHours

numMin

numSec

numMilli

set get numMinutesJScript getMinutes

(UTC) setUTCHours

"Jan5,199600:00:00" setHours(30)"Jan6,199606:00:00."

setHours

functionSetHoursDemo(nhr,nmin,nsec){vard,s;//d=newDate();// Dated.setHours(nhr,nmin,nsec);//s="Currentsettingis"+d.toLocaleString()return(s);//}

3

Date|getHours|getUTCHours|setUTCHours

Date

©2000MicrosoftCorporation

JScript

setMilliseconds

Date

dateObj.setMilliseconds(numMilli)

dateObj Date

numMilli

(UTC) setUTCMilliseconds

numMilli999()

setMilliseconds

functionSetMSecDemo(nmsec){vard,s;//varsep=":";//d=newDate();// Dated.setMilliseconds(nmsec);//s="Currentsettingis";s+=d.toLocaleString()+sep+d.getMilliseconds();return(s);//

}

3

Date|getMilliseconds|getUTCMilliseconds|setUTCMilliseconds

Date

©2000MicrosoftCorporation

JScript

setMinutes

Date

dateObj.setMinutes(numMinutes[,numSeconds[,numMilli]])

dateObj Date

numMinutes

numSeconds numMilli

numMilli

set get numSecondsJScript getSeconds

(UTC) setUTCMinutes

"Jan5,199600:00:00" setMinutes(90)"Jan5,199601:30:00"

setMinutes

functionSetMinutesDemo(nmin,nsec){

vard,s;//d=newDate();// Dated.setMinutes(nmin,nsec);//s="Currentsettingis"+d.toLocaleString()return(s);//}

1

Date|getMinutes|getUTCMinutes|setUTCMinutes

Date

©2000MicrosoftCorporation

JScript

setMonth

Date

dateObj.setMonth(numMonth[,dateVal])

dateObj Date

numMonth

dateVal getDate

(UTC) setUTCMonth

numMonth11(0)"Jan5,1996" setMonth(14)"Mar5,1997."

setMonth

functionSetMonthDemo(newmonth){vard,s;//d=newDate();// Dated.setMonth(newmonth);//s="Currentsettingis";

s+=d.toLocaleString();return(s);//}

1

Date|getMonth|getUTCMonth|setUTCMonth

Date

©2000MicrosoftCorporation

JScript

setSeconds

Date

dateObj.setSeconds(numSeconds[,numMilli])

dateObj Date

numSeconds

numMilli

set get numMilliJScript getMilliseconds

(UTC) setUTCSeconds

"Jan5,199600:00:00" setSeconds(150)"Jan5,199600:02:30."

setSeconds

functionSetSecondsDemo(nsec,nmsec){vard,s;//varsep=":";

d=newDate();// Dated.setSeconds(nsec,nmsec);//s="Currentsettingis";s+=d.toLocaleString()+sep+d.getMilliseconds();return(s);//}

1

Date|getSeconds|getUTCSeconds|setUTCSeconds

Date

©2000MicrosoftCorporation

JScript

setTime

Date

dateObj.setTime(milliseconds)

dateObj Date

millisecondsGMT197011

milliseconds1970197011285,616

setTime

setTime

functionSetTimeTest(newtime){vard,s;//d=newDate();// Dated.setTime(newtime);//s="Currentsettingis";s+=d.toUTCString();return(s);//}

1

Date|getTime

Date

©2000MicrosoftCorporation

JScript

setUTCDate

Date(UTC)

dateObj.setUTCDate(numDate)

dateObj Date

numDate

setDate

numDate Date numDate199615setUTCDate(32)199621

setUTCDate

functionSetUTCDateDemo(newdate){vard,s;//d=newDate();// Dated.setUTCDate(newdate);// UTCs="Currentsettingis";s+=d.toUTCString();return(s);//}

3

Date|getDate|getUTCDate|setDate

Date

©2000MicrosoftCorporation

JScript

setUTCFullYear

Date(UTC)

dateObj.setUTCFullYear(numYear[,numMonth[,numDate]])

dateObj Date

numYear

numMonth numDate

numDate

set get numMonthJScript getUTCMonth

setFullYear

Date1970285,616

setUTCFullYear

functionSetUTCFullYearDemo(newyear){vard,s;//d=newDate();// Dated.setUTCFullYear(newyear);// UTCs="Currentsettingis";s+=d.toUTCString();return(s);//}

3

Date|getFullYear|getUTCFullYear|setFullYear

Date

©2000MicrosoftCorporation

JScript

setUTCHours

Date(UTC)

dateObj.setUTCHours(numHours[,numMin[,numSec[,numMilli]]])

dateObj Date

numHours

numMin numSecnumMilli

numSec numMilli

numMilli

set get numMinJScript getUTCMinutes

setHours

"Jan5,199600:00:00" setHours(30)"Jan6,199606:00:00."

setUTCHours

functionSetUTCHoursDemo(nhr,nmin,nsec){vard,s;//d=newDate();// Dated.setUTCHours(nhr,nmin,nsec);// UTCs="Currentsettingis"+d.toUTCString()return(s);//}

3

Date|getHours|getUTCHours|setHours

Date

©2000MicrosoftCorporation

JScript

setUTCMilliseconds

Date(UTC)

dateObj.setUTCMilliseconds(numMilli)

dateObj Date

numMilli

setMilliseconds

numMilli999

setUTCMilliseconds

functionSetUTCMSecDemo(nmsec){vard,s;//varsep=":";//d=newDate();// Dated.setUTCMilliseconds(nmsec);// UTCs="Currentsettingis";s+=d.toUTCString()+sep+d.getUTCMilliseconds();return(s);//

}

3

Date|getMilliseconds|getUTCMilliseconds|setMilliseconds

Date

©2000MicrosoftCorporation

JScript

setUTCMinutes

Date(UTC)

dateObj.setUTCMinutes(numMinutes[,numSeconds[,numMilli]])

dateObj Date

numMinutes

numSeconds numMilli

numMilli

set get numSecondsJScriptgetUTCSeconds

setMinutes

"Jan5,199600:00:00" setUTCMinutes(70)"Jan5,199601:10:00.00."

setUTCMinutes

functionSetUTCMinutesDemo(nmin,nsec){

vard,s;//d=newDate();// Dated.setUTCMinutes(nmin,nsec);// UTCs="Currentsettingis"+d.toUTCString()return(s);//}

3

Date|getMinutes|getUTCMinutes|setMinutes

Date

©2000MicrosoftCorporation

JScript

setUTCMonth

Date (UTC)

dateObj.setUTCMonth(numMonth[,dateVal])

dateObj Date

numMonth

dateVal getUTCDate

setMonth

numMonth11(0)"Jan5,199600:00:00.00"setUTCMonth(14)"Mar5,199700:00:00.00."

setUTCMonth

functionSetUTCMonthDemo(newmonth){vard,s;//d=newDate();// Dated.setUTCMonth(newmonth);// UTCs="Currentsettingis";

s+=d.toUTCString();return(s);//}

3

Date|getMonth|getUTCMonth|setMonth

Date

©2000MicrosoftCorporation

JScript

setUTCSeconds

Date(UTC)

dateObj.setUTCSeconds(numSeconds[,numMilli])

dateObj Date

numSeconds

numMilli

set get numMilliJScriptgetUTCMilliseconds

setSeconds

"Jan5,199600:00:00" setSeconds(150)"Jan5,199600:02:30.00."

setSeconds

functionSetUTCSecondsDemo(nsec,nmsec){vard,s;//d=newDate();// Date

d.setUTCSeconds(nsec,nmsec);// UTCs="CurrentUTCmillisecondssettingis";s+=d.getUTCMilliseconds();//return(s);//}

3

Date|getSeconds|getUTCSeconds|setSeconds

Date

©2000MicrosoftCorporation

JScript

setYear

Date

dateObj.setYear(numYear)

dateObj Date

numYear1900

setFullYear

Date1997 setYear(97)2010 setYear(2010)0-99setFullYear

JScript1.0 setYear numYear19001899 numYear-12000 numYear100

1

Date|getFullYear|getUTCFullYear|getYear|setFullYear|setUTCFullYear

Date

©2000MicrosoftCorporation

JScript

shift

arrayObj.shift()

arrayObj Array

shift

5.5

unshift

Array

©2000MicrosoftCorporation

JScript

sin

Math.sin(number)

number

1

acos|asin|atan|cos|Math|tan

Math

©2000MicrosoftCorporation

JScript

slice(Array)

arrayObj.slice(start,[end])

arrayObj Array

startarrayObj

endarrayObj

slice Array arrayObj

slice end start length+start length end length+end length end slice arrayObjend start

myArray newArray

newArray=myArray.slice(0,-1)

3

slice(String) |String

Array

©2000MicrosoftCorporation

JScript

slice(String)

stringObj.slice(start,[end])

stringObj String

start0 stringObj

end0 stringObj

slice stringObj String

slice end start length+start length end length+end length end slice arrayObjend start

slice-1str1

str1.slice(0)str2.slice(0,-1)

3

Array|slice(Array) |String

String

©2000MicrosoftCorporation

JScript

small

HTML<SMALL> String

strVariable.small()"StringLiteral".small()

small

varstrVariable="Thisisastring";strVariable=strVariable.small(); strVariable

<SMALL>Thisisastring</SMALL>

1

big|String|String

String

©2000MicrosoftCorporation

JScript

sort

Array

arrayobj.sort(sortfunction)

arrayObj Array

sortFunctionASCII

sort Array Array

sortfunction

sort

functionSortDemo(){vara,l;//a=newArray("X","y","d","Z","v","m","r");l=a.sort();//return(l);//

}

2

Array

Array

©2000MicrosoftCorporation

JScript

splice

arrayObj.splice(start,deleteCount,[item1[,item2[,...[,itemN]]]])

arrayObj Array

start0

deleteCount

item1,item2,...,itemN

splice start arrayObj Array

5.5

slice(Array)

Array

©2000MicrosoftCorporation

JScript

split

stringObj.split([separator[,limit]])

stringObj String split

separator

limit

split stingObj separator separator

split

functionSplitDemo(){vars,ss;vars="TheraininSpainfallsmainlyintheplain.";//ss=s.split("");return(ss);}

3

concat|RegExp|||String

String

©2000MicrosoftCorporation

JScript

sqrt

Math.sqrt(number)

number

number

1

Math|SQRT1_2|SQRT2

Math

©2000MicrosoftCorporation

JScript

strike

HTML<STRIKE> String

strVariable.strike()"StringLiteral".strike()

strike

varstrVariable="Thisisastringobject";strVariable=strVariable.strike(); strVariable

<STRIKE>Thisisastringobject</STRIKE>

1

String|String

String

©2000MicrosoftCorporation

JScript

sub

HTML<SUB> String

strVariable.sub()"StringLiteral".sub()

sub

varstrVariable="Thisisastringobject";strVariable=strVariable.sub(); strVariable

<SUB>Thisisastringobject</SUB>

1

String|String|sup

String

©2000MicrosoftCorporation

JScript

substr

stringvar.substr(start[,length])

stringvar String

start0

length

length0 stringvar

substr

functionSubstrDemo(){vars,ss;//vars="TheraininSpainfallsmainlyintheplain.";ss=s.substr(12,5);//return(ss);// "Spain"}

3

String|String|substring

String

©2000MicrosoftCorporation

JScript

substring

String

strVariable.substring(start,end)"StringLiteral".substring(start,end)

start0

end0

substring start end

substring start end strvar.substring(0,3)strvar.substring(3,0)

start end NaN0

start end strvar.substring(0,3) strvar.substring(3,0)3

substring

functionSubstringDemo(){varss;//vars="TheraininSpainfallsmainlyintheplain..";ss=s.substring(12,17);//

return(ss);//}

1

String|String|substr

String

©2000MicrosoftCorporation

JScript

sup

HTML<SUP> String

strVariable.sup()"StringLiteral".sup()

sup

varstrVariable="Thisisastringobject";strVariable=strVariable.sup(); strVariable

<SUP>Thisisastringobject</SUP>

1

String|String|sub

String

©2000MicrosoftCorporation

JScript

tan

Math.tan(number)

number

number

1

acos|asin|atan|atan2|cos|Math|sin

Math

©2000MicrosoftCorporation

JScript

test

Boolean

rgexp.test(str)

rgexp

str

test true false

RegExp test

test

functionTestDemo(re,s){vars1;////if(re.test(s))//s1="contains";//selses1="doesnotcontain";//sreturn("'"+s+"'"+s1+"'"+re.source+"'");//

}

3

RegExp||||

©2000MicrosoftCorporation

JScript

toArray

VBArrayJScript

safeArray.toArray()

safeArray VBArray

VBArrayJScriptVBArrayJScript

VBArray(1,2,3),(4,5,6),(7,8,9)JScript1,2,3,4,5,6,7,8,9

JScriptVBArray

VisualBasicVBScriptJScriptVBJScriptHTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1Fori=0To2Forj=0To2a(j,i)=kdocument.writeln(k)

k=k+1Nextdocument.writeln("<BR>")NextCreateVBArray=aEndFunction--></SCRIPT>

<SCRIPTLANGUAGE="JScript"><!--functionVBArrayTest(vbarray){vara=newVBArray(vbarray);varb=a.toArray();vari;for(i=0;i<9;i++){document.writeln(b[i]);}}--></SCRIPT></HEAD>

<BODY><SCRIPTLANGUAGE="JScript"><!--

VBArrayTest(CreateVBArray());--></SCRIPT></BODY>

3

dimensions|getItem|lbound|ubound

VBArray

©2000MicrosoftCorporation

JScript

toDateString

objDate.toDateString()

objDate Date

toDateString

5.5

toTimeString|toLocaleDateString

Date

©2000MicrosoftCorporation

JScript

toExponential

numObj.toExponential([fractionDigits])

numObj Number

fractionDigits0–20020

toExponential fractionDigits

fractionDigits toExponential

5.5

toFixed|toPrecision

Number

©2000MicrosoftCorporation

JScript

toFixed

numObj.toFixed([fractionDigits])

numObj Number

fractionDigits0–20020

toFixed fractionDigits

fractionDigits undefinedtoFixed0

5.5

toExponential|toPrecision

Number

©2000MicrosoftCorporation

JScript

toGMTString

(GMT)

dateObj.toGMTString()

toGMTString toUTCString

toGMTString StringGMT"05Jan199600:00:00GMT"

1

Date|toUTCString

Date

©2000MicrosoftCorporation

JScript

toLocaleDateString

objDate.toLocaleDateString()

objDate Date

toLocaleDateString toLocalDateString–

5.5

toDateString|toLocaleTimeString

Date

©2000MicrosoftCorporation

JScript

toLocaleLowerCase

stringVar.tolocaleLowerCase()

stringVar String

toLocaleLowerCase toLowerCaseUnicode

5.5

toLocaleUpperCase|toLowerCase

String

©2000MicrosoftCorporation

JScript

toLocaleString

dateObj.toLocaleString()

dateObj Date

toLocaleString String

16011999“”“”

F toString

15 toLocaleString"01/05/9600:00:00""05/01/9600:00:00"

toLocaleString

toLocaleString

vard,s;//d=newDate();// Dates="Currentsettingis";s+=d.toLocaleString();//return(s);//}

1

Date

Array|Date|Number|Object

©2000MicrosoftCorporation

JScript

toLocaleTimeString

objDate.toLocaleTimeString()

objDate Date

toLocaleTimeString toLocalTimeString–

5.5

ToTimeString|toLocaleDateString

Date

©2000MicrosoftCorporation

JScript

toLocaleUpperCase

stringVar.tolocaleUpperCase()

stringVar String

toLocaleUpperCase toUpperCaseUnicode

5.5

toLocaleLowerCase|toUpperCase

String

©2000MicrosoftCorporation

JScript

toLowerCase

strVariable.toLowerCase()"StringLiteral".toLowerCase()

toLowerCase

ofthe toLowerCase

varstrVariable="ThisisaSTRINGobject";strVariable=strVariable.toLowerCase(); strVariable

thisisastringobject

1

String|String|toUpperCase

String

©2000MicrosoftCorporation

JScript

toPrecision

numObj.toPrecision([precision])

numObj Number

precision1–21121

precision-1 precision

precision undefined toString

5.5

toFixed|toExponential

Number

©2000MicrosoftCorporation

JScript

toString

objectname.toString([radix])

objectname

radix

toStringJScript

Array ArrayBoolean Boolean true“true”“false”DateError

Function

functionname toString

functionfunctionname(){[nativecode]}NumberString String

“ [objectobjectname]” objectname

radixtoStringRadix

functionCreateRadixTable(){

vars,s1,s2,s3,x;//s="HexDecBin\n";//for(x=0;x<16;x++)//{//switch(x)//{//case0:s1="";s2="";s3="";break;case1:s1="";s2="";s3="";break;case2:s3="";break;case3:s3="";break;case4:s3="";break;case5:s3="";break;

case6:s3="";break;case7:s3="";break;case8:s3="";break;case9:s3="";break;default:s1="";s2="";s3="";}//s+=""+x.toString(16)+s1+x.toString(10)s+=s2+s3+x.toString(2)+"\n";}return(s);// radix}

2

function

Array|Boolean|Date|Error|Function|Number|Object|String

©2000MicrosoftCorporation

JScript

toTimeString

objDate.toTimeString()

objDate Date

toTimeString

5.5

toDateString|toLocaleTimeString

Date

©2000MicrosoftCorporation

JScript

toUpperCase

strVariable.toUpperCase()"StringLiteral".toUpperCase()

toUpperCase

toUpperCase

varstrVariable="ThisisaSTRINGobject";strVariable=strVariable.toUpperCase(); strVariable

THISISASTRINGOBJECT

1

String|String|toLowerCase

String

©2000MicrosoftCorporation

JScript

toUTCString

(UTC)

dateObj.toUTCString()

dateObj Date

toUTCString StringUTC

toUTCString

functiontoUTCStrDemo(){vard,s;//d=newDate();// Dates="Currentsettingis";s+=d.toUTCString();// UTCreturn(s);// UTC}

3

Date|toGMTString

Date

©2000MicrosoftCorporation

JScript

ubound

VBArray

safeArray.ubound(dimension)

safeArray VBArray

dimensionVBArray ubound1

VBArray ubound undefined dimVBArray“”

VisualBasicVBScriptJScriptHTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1Fori=0To2

Forj=0To2a(j,i)=kk=k+1NextNextCreateVBArray=aEndFunction--></SCRIPT>

<SCRIPTLANGUAGE="JScript"><!--functionVBArrayTest(vba){vari,s;vara=newVBArray(vba);for(i=1;i<=a.dimensions();i++){s="Theupperboundofdimension";s+=i+"is";s+=a.ubound(i)+".<BR>";return(s);}}--></SCRIPT></HEAD>

<BODY><SCRIPTlanguage="jscript">document.write(VBArrayTest(CreateVBArray()));</SCRIPT></BODY>

3

dimensions|getItem|lbound|toArray

VBArray

©2000MicrosoftCorporation

JScript

unescape

escape String

unescape(charstring)

charstring String

unescape charstring% xx ASCII

%uxxxxUnicode xxxxUnicode.

unescape(URI) decodeURI decodeURIComponent

1

DecodeURI|decodeURIComponent|escape|String

Global

©2000MicrosoftCorporation

JScript

unshift

arrayObj.unshift([item1[,item2[,...[,itemN]]]])

arrayObj Array

item1,item2,...,itemN Array

unshift

5.5

shift

Array

©2000MicrosoftCorporation

JScript

UTC

(UTC) (GMT)197011

Date.UTC(year,month,day[,hours[,minutes[,seconds[,ms]]]])

year year099 year1900+ year

month011()

day131

hours minutes023(11pm)

minutes seconds059

seconds milliseconds059

ms0999

UTCUTC197011 setTime Date150JScript230

UTC Date UTCUTC Date

UTC Date

year099 1900+year

UTC

functionDaysBetweenDateAndNow(yr,mo,dy){vard,r,t1,t2,t3;//varMinMilli=1000*60//varHrMilli=MinMilli*60varDyMilli=HrMilli*24t1=Date.UTC(yr,mo-1,dy)// 1/1/1970d=newDate();// Datet2=d.getTime();//if(t2>=t1)t3=t2-t1;elset3=t1-t2;r=Math.round(t3/DyMilli);return(r);//}

1

Date|setTime

Date

©2000MicrosoftCorporation

JScript

valueOf

object.valueOf()

objectJScript

JScript valueOf

Array Array.toString Array.joinBoolean BooleanDate 197011 UTCFunctionNumberObjectString

Math Error valueOf

2

toString

Array|Boolean|Date|Function|Number|Object|String

©2000MicrosoftCorporation

JScript

JScript

Automation ActiveXObject

ArrayBoolean Boolean

DateDictionaryEnumerator

JScript ErrorFileSystemObject

FunctionGlobalMathNumber

JScript ObjectRegExp

StringVisualBasic VBArray

©2000MicrosoftCorporation

JScript

ActiveXObject

Automation

newObj=newActiveXObject(servername.typename[,location])

ActiveXObject

newObj ActiveXObject

servername

typename

location

Automation

Automation ActiveXObject

varExcelSheet;ExcelApp=newActiveXObject("Excel.Application");ExcelSheet=newActiveXObject("Excel.Sheet");MicrosoftExcelExcelSheetExcelApplicationActiveSheet.Cells

//Excel ApplicationExcelSheet.Application.Visible=true;//ExcelSheet.ActiveSheet.Cells(1,1).Value="ThisiscolumnA,row1";//ExcelSheet.SaveAs("C:\\TEST.XLS");//Application Quit ExcelExcelSheet.Application.Quit();

Internet ActiveXObject servername"\\myserver\public" servername"myserver"DNSIPservername

"myserver"Excel

functionGetAppVersion(){varXLApp=newActiveXObject("Excel.Application",return(XLApp.Version);}

1

GetObject

©2000MicrosoftCorporation

JScript

Array

arrayObj=newArray()arrayObj=newArray([size])arrayObj=newArray([element0[,element1[,...[,elementN]]]])

arrayObj Array

size size-1

element0,...,elementN n+1n+1

[]

varmy_array=newArray();for(i=0;i<10;i++){my_array[i]=i;}x=my_array[4];

MicrosoftJScript4

Array32400

Array length1

JScript

constructor|length|prototype

concat|join|pop|push|reverse|shift|slice|sort|splice|toLocaleString|toString|unshift|valueOf

2

new

©2000MicrosoftCorporation

JScript

Boolean

Boolean

boolObj=newBoolean([boolValue])

boolObj Boolean

boolValueBoolean Boolvalue false0 null NaN Booleanfalse true

BooleanBoolean Boolean BooleanJScript Boolean

Boolean

constructor|prototype

toString|valueOf

2

new|var

©2000MicrosoftCorporation

JScript

Date

dateObj=newDate()dateObj=newDate(dateVal)dateObj=newDate(year,month,date[,hours[,minutes[,seconds[,ms]]]])

dateObj Date

dateValdateVal197011 dateVal parse

dateValActiveX(R)VT_DATE

year197676

month011112

date131

hours minutes02311pm

minutes seconds059

seconds milliseconds059

ms

0999

Date150JScript230

NaN Date(UTC)

Date197011285,616

Date Date parse UTC

Date

functionDateDemo(){vard,s="Today'sdateis:";//d=newDate();// Dates+=(d.getMonth()+1)+"/";//s+=d.getDate()+"/";//s+=d.getYear();//return(s);//}

constructor|prototype

getDate|getDay|getFullYear|getHours|getMilliseconds|getMinutes|getMonth|getSeconds|getTime|getTimezoneOffset|

getUTCDate|getUTCDay|getUTCFullYear|getUTCHours|getUTCMilliSeconds|getUTCMinutes|getUTCMonth|getUTCSeconds|getVarDate|getYear|setDate|setFullYear|setHours|setMilliSeconds|setMinutes|setMonth|setSeconds|setTime|setUTCDate|setUTCFullYear|setUTCHours|setUTCMilliseconds|setUTCMinutes|setUTCMonth|setUTCSeconds

|setYear|toGMTString|toLocaleString|toUTCString|toString|valueOf|parse|UTC

1

new|var

©2000MicrosoftCorporation

JScript

Enumerator

enumObj=newEnumerator([collection])

enumObj Enumerator

collection Collection

EnumeratorVBScript For...Each

Enumerator:

functionShowDriveList(){varfso,s,n,e,x;//fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);// Enumerators="";for(;!e.atEnd();e.moveNext())//{x=e.item();

s=s+x.DriveLetter;s+="-";if(x.DriveType==3)//n=x.ShareName;//elseif(x.IsReady)//n=x.VolumeName;//elsen="[ ]";s+=n+"<br>";}return(s);//}

Enumerator

atEnd|item|moveFirst|moveNext

3

Drives|Files|Folders

©2000MicrosoftCorporation

JScript

Error

varnewErrorObj=newError()varnewErrorObj=newError(number)varnewErrorObj=newError(number,description)

Error

number

description

Error description number

3216

Error throw Error

try...catch Error

Error

try{x=y//}catch(e){// eresponse.write(e)// "[objectError]".response.write(e.number&0xFFFF)// 5009response.write(e.description)// "'y'isundefined".}

Error

description|number

5

new|throw|try...catch|var

©2000MicrosoftCorporation

JScript

Function

1functionfunctionName([argname1[,...[,argnameN]]]){body}

2functionName=newFunction([argname1,[...argnameN,]]body);

functionName

argname1...argnameN

bodyJScript

JScript1JScript FunctionJScript2 Fnction

1JScript2

1

functionadd(x,y){return(x+y);//}

2

varadd=newFunction("x","y","return(x+y)");

add(2,3);

arguments|caller|constructor|prototype

toString|valueOf

2

function|new|var

©2000MicrosoftCorporation

JScript

Global

Global

Global newScripting

Infinity|NaN

escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape

5

Object

©2000MicrosoftCorporation

JScript

Math

Math.[{property|method}]

propertyMath

methodMath.

Math new

E|LN2|LN10|LOG2E|LOG10E|PI|SQRT1_2|SQRT2

abs|acos|asin|atan|atan2|ceil|cos|exp|floor|log|max|min|pow|random|round|sin|sqrt|tan

1

Number

©2000MicrosoftCorporation

JScript

Number

numObj=newNumber(value)

numobj Number

valueRequired.Thenumericvalueofthe Numberobjectbeingcreated.

value

JScript Number Number

Number toString

MAX_VALUE|MIN_VALUE|NaN|NEGATIVE_INFINITY|POSITIVE_INFINITY|constructor|prototype

toLocaleString|toString|valueOf

1

Math|new

©2000MicrosoftCorporation

JScript

Object

JScript

obj=newObject([value])

obj Object

valueJScript NumberBooleanStringvaluevalue nullundefined

ObjectJScriptJScript toString Object

ObjectJScript

prototype|constructor

toLocaleString|toString|valueOf

3

Function|Global

©2000MicrosoftCorporation

JScript

RegExp

RegExp.property

property RegExp

RegExp RegExp

index -1lastIndex -1lastMatch $&lastParen $+leftContext rightContext $1-$9 $1-$9

undefined

RegExp RegExp

RegExp

functionmatchDemo(){vars;varre=newRegExp("d(b+)(d)","ig");varstr="cdbBdbsbdbdz";vararr=re.exec(str);s="$1contains:"+RegExp.$1+"\n";

s+="$2contains:"+RegExp.$2+"\n";s+="$3contains:"+RegExp.$3;return(s);}

$1...$9|index|input|lastIndex|lastMatch|lastParen|leftContext|rightContext

RegExp

3

||String

©2000MicrosoftCorporation

JScript

1re=/pattern/[flags]

2re=newRegExp("pattern",["flags"])

re

Pattern1"/"2

flags2flag

g pattern

i

m

RegExp RegExp

RegExp

12

pattern1 pattern2 pattern compile

(re) match

functionMatchDemo(){varr,re;//vars="TheraininSpainfallsmainlyintheplain";re=newRegExp("Spain","i");//r=s.match(re);// sreturn(r);//}

lastIndex|source

compile|exec|test

3

RegExp||String

©2000MicrosoftCorporation

JScript

String

newString=newString(["stringLiteral"])

newString String

stringLiteralUnicode

String String new String

varalpha,beta;alpha=" ";beta=" ";

alpha.test=10;

beta test

vargamma,delta;gamma=newString(" ");delta=newString(" ");

gamma.test=10;

delta test newString String String

constructor|length|prototype

anchor|big|blink|bold|charAt|charCodeAt|concat|fixed|fontcolor|fontsize|fromCharCode|indexOf|italics|

lastIndexOf|link|match|replace|search|slice|small|split|strike|sub|substr|substring|sup|toLowerCase|

toUpperCase|toString|valueOf

1

new

©2000MicrosoftCorporation

JScript

VBArray

VisualBasic

varName=newVBArray(safeArray)

varNameVBArray

safeArrayVBArray

VBArrays VBArray safeArray VBArrayActiveX

VBArrays dimensions lbound ubound

VisualBasicVBScriptVBJScriptJScriptHTML<HEAD><BODY>JScript

<HEAD><SCRIPTLANGUAGE="VBScript"><!--FunctionCreateVBArray()Dimi,j,kDima(2,2)k=1

Fori=0To2Forj=0To2a(j,i)=kdocument.writeln(k)k=k+1Nextdocument.writeln("vbCRLF")NextCreateVBArray=aEndFunction--></SCRIPT>

<SCRIPTLANGUAGE="JScript"><!--functionVBArrayTest(vbarray){vara=newVBArray(vbarray);varb=a.toArray();vari;for(i=0;i<9;i++){document.writeln(b[i]);}}--></SCRIPT></HEAD>

<BODY><SCRIPTLANGUAGE="JScript"><!--VBArrayTest(CreateVBArray());--></SCRIPT></BODY>

VBArray

dimensions|getItem|lbound|toArray|ubound

3

Array

©2000MicrosoftCorporation

JScript

JScript

+=&<<~|>>^,

Boolean

?:--

. delete/==>>====++!=

Boolean instanceof<<=&&!||%*new!==

JScript-typeof->>>void

©2000MicrosoftCorporation

JScript

JScript

JScript

.[]()++---~!deletenewtypeofvoid*/%+-+<<>>>>><<=>>=instanceof instanceof==!====!==&^|&&||?:=oP=,

z=78*(96+3+45)

=,*,(),+,+(),+,+,*,=

1. 96345144

2. 7814411232

A11232z

©2000MicrosoftCorporation

JScript

+--/++%*---

,?:==>>====!=<<=&&!||!==

&<<~|

>>^>>>

delete

instanceof

new

typeof

void

1

©2000MicrosoftCorporation

JScript

(+=)

result+=expression

result

expression

result=result+expression

+=

Boolean

1

+||

©2000MicrosoftCorporation

JScript

(+)

result=expression1+expression2

result

expression1

expression2

+

Boolean

1

+=||

©2000MicrosoftCorporation

JScript

(=)

result=expression

result

expression

=

j=k=l=0;jkl

1

|

©2000MicrosoftCorporation

JScript

“”(&=)

“”

result&=expression

result.

expression.

:

result=result&expression

&= result expression,“”

0101(result)1100(expression)----0100

110

1

&||

©2000MicrosoftCorporation

JScript

“”(&)

“”

result=expression1&expression2

result

expression1

expression2

&“”

0101(expression1)1100(expression2)----0100(result)

110

1

&=||

©2000MicrosoftCorporation

JScript

(<<)

result=expression1<<expression2

result

expression1

expression2

<< expression1 expression2

vartemptemp=14<<2 temp5614000011105600111000

1

<<= |>> |>>> ||

©2000MicrosoftCorporation

JScript

“”(~)

“”

result=~expression

result

expression

~

undefined null

Booleanfalse0true1

~

0101(expression)----1010(result)

1001

1

!||

©2000MicrosoftCorporation

JScript

“”(|=)

“”

result|=expression

result

expression

result=result|expression

|= result expression“”

0101(result)1100(expression)----1101( )

110

1

|||

©2000MicrosoftCorporation

JScript

“”(|)

“”

result=expression1|expression2

result

expression1

expression2

|“”

0101(expression1)1100(expression2)----1101( )

110

1

|= ||

©2000MicrosoftCorporation

JScript

(>>)

result=expression1>>expression2

result

expression1

expression2

>> expression1 expression2 expression1 temp-4-1411110010-411111100

vartemptemp=-14>>2

1

<< |>>= |>>> ||

©2000MicrosoftCorporation

JScript

“”(^=)

result^=expression

result

expression

^=

result=result^expression

^=

0101(result)1100(expression)----1001

110

1

^||

©2000MicrosoftCorporation

JScript

“”(^)

result=expression1^expression2

result

expression1

expression2

^

0101(expression1)1100(expression2)----1001( )

110

1

^= ||

©2000MicrosoftCorporation

JScript

(,)

expression1,expression2

expression1

expression2

, , for

for(i=0;i<10;i++,j++){k=i+j;}

for ,

1

for||

©2000MicrosoftCorporation

JScript

Boolean

expression1comparisonoperatorexpression2

expression1

comparisonoperator

expression2

JScriptUnicode

expression1 expression2

<><=>=

expression1expression2

NaN false

==!=

Boolean

NaN

nullnullundefined

Boolean

===!==

1

|

©2000MicrosoftCorporation

JScript

+=&=|=^=/=<<=%=*=>>=-=>>>=

©2000MicrosoftCorporation

JScript

(?:)

test?1:2

testBoolean

1 test true

2 test false

?: if...else if...else

varnow=newDate();vargreeting="Good"+((now.getHours()>17)?"evening."6pm"Goodevening." if...else

varnow=newDate();vargreeting="Good";if(now.getHours()>17)greeting+="evening.";elsegreeting+="day.";

1

if...else||

©2000MicrosoftCorporation

JScript

delete

deleteexpression

expressionJScript

expression expression false

true

3

|

©2000MicrosoftCorporation

JScript

(/=)

result/=expression

result

expression

/=

result=result/expression

1

/||

©2000MicrosoftCorporation

JScript

(/)

result=number1/number2

result

number1

number2

1

/=||

©2000MicrosoftCorporation

JScript

in

result=propertyinobject

result

property

object

inproperty

1

|

©2000MicrosoftCorporation

JScript

(++)(--)

1result=++variableresult=--variableresult=variable++result=variable--

2++variable--variablevariable++variable--

result

variable

varj,k;k=2;j=++k;

3 j

varj,k;k=2;j=k++;2j

1

|

©2000MicrosoftCorporation

JScript

instanceof

Boolean

result=objectinstanceofclass

result

object

class

object class instanceof true object object nullfalse

instanceof

functionobjTest(obj){vari,t,s="";//t=newArray();//t["Date"]=Date;//t["Object"]=Object;t["Array"]=Array;

for(iint){if(objinstanceoft[i])// obj{s+="objisaninstanceof"+i+"\n";}else{s+="objisnotaninstanceof"+i+"\n";}}return(s);//}

varobj=newDate();response.write(objTest(obj));

5

|

©2000MicrosoftCorporation

JScript

(<<=)

result<<=expression

result

expression

<<=

result=result<<expression

<<= result expression

vartemptemp=14temp<<=2 temp5614000011105600111000

1

<<|>> |>>> ||

©2000MicrosoftCorporation

JScript

“”(&&)

result=expression1&&expression2

result

expression1

expression2

True result True False result False

JScriptBooleanBoolean

true

false

nullundefinedfalse

false

1

|

©2000MicrosoftCorporation

JScript

“”(!)

result=!expression

result

expression

result

expression result

True FalseFalse True

!

undefined null

Booleanfalse0true1

! expression result expression result1

1

~||

©2000MicrosoftCorporation

JScript

“”(||)

“”

result=expression1||expression2

result

expression1

expression2

True result True result

expression1 expression2 result

True True TrueTrue False TrueFalse True TrueFalse False False

JScriptBooleanBoolean

true

false

null undefinedfalse

0false

1

|

©2000MicrosoftCorporation

JScript

(%=)

result%=expression

result

expression

%=

result=result%expression

1

%||

©2000MicrosoftCorporation

JScript

(%)

result=number1%number2

result

number1

number2

number1 number2 resultA result5

A=19%6.7

1

%=||

©2000MicrosoftCorporation

JScript

(*=)

result*=expression

result

expression

*=

result=result*expression

1

*||

©2000MicrosoftCorporation

JScript

(*)

result=number1*number2

result

number1

number2

1

*=||

©2000MicrosoftCorporation

JScript

new

newconstructor[(arguments)]

constructor

arguments

new

this

new

my_object=newObject;my_array=newArray();my_date=newDate("Jan51996");

1

function

©2000MicrosoftCorporation

JScript

(>>=)

result>>=expression

result

expression

>>=

result=result>>expression

>>= result expression result temp-4-1411110010-411111100

vartemptemp=-14temp>>=2

1

<< |>> |>>> ||

©2000MicrosoftCorporation

JScript

(-=)

result-=expression

result

expression

-=

result=result-expression

1

-||

©2000MicrosoftCorporation

JScript

(-)

1result=number1-number2

2-number

result

number

number1

number2

1 -2 -

2

undefined null

Booleanfalse0true1

2 result result

1

-=||

©2000MicrosoftCorporation

JScript

typeof

typeof[()expression[]];

expression

typeof typeof"number,""string,""boolean,""object,""function,""undefined."

typeof

1

|

©2000MicrosoftCorporation

JScript

(>>>)

result=expression1>>>expression2

result

expression1

expression2

>>> expression1 expression2

vartemptemp=-14>>>2 temp-1411111111111111111111111111110010107374182000111111111111111111111111111100

1

>>>= |<< |>> ||

©2000MicrosoftCorporation

JScript

(>>>=)

result>>>=expression

result

expression

>>>=

result=result>>>expression

>>>= result expression

vartemptemp=-14temp>>>=2 temp-1411111111111111111111111111110010107374182000111111111111111111111111111100

1

>>> |<< |>> ||

©2000MicrosoftCorporation

JScript

void

voidexpression

expressionJScript

void undefined

2

|

©2000MicrosoftCorporation

JScript

JScript

$1...$9Propertiesargumentscallerconstructordescription

Euler Eindex

Number.POSITIVE_INFINITY InfinityinputlastIndex

1 lengthArraylengthFunction

String lengthString2 LN210 LN102eEuler LOG2E10eEuler LOG10EJScript MAX_VALUEJScript MIN_VALUE NaN NaNGlobal NaN NaNNumberJScript-Number.MAX_VALUE NEGATIVE_INFINITY

number3.141592653589793 PIJScriptNumber.MAX_VALUE POSITIVE_INFINITY

prototypesource

0.512 SQRT1_22 SQRT2

©2000MicrosoftCorporation

JScript

$1...$9

RegExp.$n

RegExp RegExp

n

19.

$1...$9

$1...$9

functionmatchDemo(){vars;varre=newRegExp("d(b+)(d)","ig");varstr="cdbBdbsbdbdz";vararr=re.exec(str);s="$1contains:"+RegExp.$1+"\n";s+="$2contains:"+RegExp.$2+"\n";s+="$3contains:"+RegExp.$3;return(s);}

1

RegExp|

RegExp

©2000MicrosoftCorporation

JScript

arguments

functionarguments

function.arguments

function

arguments arguments length arguments

arguments

functionArgTest(){vari,s,numargs=arguments.length;s=numargs;if(numargs<2)s+="argumentwaspassedtoArgTest.Itwas";elses+="argumentswerepassedtoArgTest.Theywere";for(i=0;i<numargs;i++){s+=arguments[i]+"";}return(s);}

2

function|length(Array)

Function

©2000MicrosoftCorporation

JScript

caller

functionName.caller

functionName

callerJScript caller null

caller functionName.toString

caller

functionCallLevel(){if(CallLevel.caller==null)return("CallLevelwascalledfromthetoplevel.");elsereturn("CallLevelwascalledbyanotherfunction.");}

2

function

Function

©2000MicrosoftCorporation

JScript

constructor

object.constructor

object

constructorprototype Global Math JScriptconstructor

x=newString("Hi");if(x.constructor==String)//

functionMyFunc{//}

y=newMyFunc;if(y.constructor==MyFunc)//

2

prototype

Array|Boolean|Date|Function|Math|Number|Object|String

©2000MicrosoftCorporation

JScript

description

object.description[=stringExpression]

description

objectError

stringExpression

description

description

tryx=y//catch(vare){// edocument.write(e)// "[objectError]".document.write((e.number&0xFFFF))// 5009.document.write(e.description)// "'y'isundefined".}

5

number

Error

©2000MicrosoftCorporation

JScript

E

Euler E2.718

numVar=Math.E

1

exp|Math

Math

©2000MicrosoftCorporation

JScript

global

Booleanglobal(g) false

rgExp.global

rgExp

global global true false

global

global"g""the""a""The""the""t"

gi m

functionRegExpPropDemo(flag){if(flag.match(/[^gim]/))//return("Flagspecifiedisnotvalid");varr,re,s//varss="Themanhittheballwiththebat.\n";ss+="whilethefieldercaughttheballwiththeglove.";re=newRegExp("the",flag);//r=ss.replace(re,"a");//"a" "the"s="RegularExpressionpropertyvalues:\n\n"s+="globalignoreCasemultiline\n"if(re.global)// global

s+="True";elses+="False";if(re.ignoreCase)// ignoreCases+="True";elses+="False";if(re.multiline)// multilines+="True";elses+="False";s+="\n\nTheresultingstringis:\n\n"+r;return(s);//}

5.5

ignoreCase|multiline|

RegExp

©2000MicrosoftCorporation

JScript

hasOwnProperty

object.hasOwnProperty(proName)

object

proName

object hasOwnProperty true false

Stringsplit false true

vars=newString("JScript");print(s.hasOwnProperty("split"));print(String.prototype.hasOwnProperty("split"));

5.5

in

Object

©2000MicrosoftCorporation

JScript

ignoreCase

BooleanignoreCase( i) false

rgExp.ignoreCase

rgExp RegExp

ignoreCase ignoreCase true false

ignoreCase

ignoreCase"i""the""a""The"ignoreCase"T""t"

gi m

functionRegExpPropDemo(flag){if(flag.match(/[^gim]/))//return("Flagspecifiedisnotvalid");varr,re,s//varss="Themanhittheballwiththebat.\n";ss+="whilethefieldercaughttheballwiththeglove.";re=newRegExp("the",flag);//r=ss.replace(re,"a");// "a" "the"s="RegularExpressionpropertyvalues:\n\n"s+="globalignoreCasemultiline\n"if(re.global)// global

s+="True";elses+="False";if(re.ignoreCase)// ignoreCases+="True";elses+="False";if(re.multiline)// multilines+="True";elses+="False";s+="\n\nTheresultingstringis:\n\n"+r;return(s);//}

5.5

global|multiline|

RegExp

©2000MicrosoftCorporation

JScript

index

RegExp.index

RegExp

index-1

index index lastIndex

functionRegExpTest(){varver=Number(ScriptEngineMajorVersion()+"."+ScriptEngineMinorVersion())if(ver>=5.5){varsrc="TheraininSpainfallsmainlyintheplain.";varre=/\w+/g;vararr;while((arr=re.exec(src))!=null)print(arr.index+"-"+arr.lastIndex+"\t"+arr);}else{alert("YouneedanewerversionofJScriptforthistowork");}}

3

RegExp|

RegExp

©2000MicrosoftCorporation

JScript

Infinity

Number.POSITIVE_INFINITY

Infinity

Infinity GlobalScripting

3

POSITIVE_INFINITY|NEGATIVE_INFINITY

Global

©2000MicrosoftCorporation

JScript

input($_)

RegExp.input

RegExp

input

input

functioninputDemo(){vars;varre=newRegExp("d(b+)(d)","ig");varstr="cdbBdbsbdbdz";vararr=re.exec(str);s="Thestringusedforthematchwas"+RegExp.inputreturn(s);}

3

RegExp|

RegExp

©2000MicrosoftCorporation

JScript

isPrototypeOf

object1.isPrototypeOf(object2)

object1

object2

object2 object1 isPrototypeOf true object2 object1object2 isPrototypeOf false

isPrototypeOf

functiontest(){varre=newRegExp();//return(RegExp.prototype.isPrototypeOf(re));// true}

Object

©2000MicrosoftCorporation

JScript

lastIndex

RegExp.lastIndex

RegExp

lastIndex-1

lastIndexRegExpexectestStringmatchreplacesplit

lastIndex

lastIndex-1.

lastIndex test exec lastIndex-1

lastIndex lastIndex-1

lastIndex

lastIndex index lastIndex

functionRegExpTest(){varver=Number(ScriptEngineMajorVersion()+"."+ScriptEngineMinorVersion())if(ver>=5.5){varsrc="TheraininSpainfallsmainlyintheplain.";varre=/\w+/g;vararr;while((arr=re.exec(src))!=null)print(arr.index+"-"+arr.lastIndex+"\t"+arr);

}else{alert("YouneedanewerversionofJScriptforthistowork");}}

3

RegExp|

RegExp

©2000MicrosoftCorporation

JScript

length(Array)

1

numVar=arrayObj.length

numVar

arrayObj Array

lengthmy_array.length72

varmy_array=newArray();my_array[0]="Test";my_array[6]="AnotherTest";

length length

length undefined

length:

functionLengthDemo(){vara;a=newArray(0,1,2,3,4);return(a.length);}

2

length(Function) |length(String)

Array

©2000MicrosoftCorporation

JScript

length(Function)

functionName.length

functionName

lengthScripting

length

length

functionArgTest(a,b){vari,s="TheArgTestfunctionexpected";varnumargs=ArgTest.arguments.length;varexpargs=ArgTest.length;if(expargs<2)s+=expargs+"argument.";elses+=expargs+"arguments.";if(numargs<2)s+=numargs+"waspassed.";elses+=numargs+"werepassed.";return(s);}

2

arguments|length(Array) |length(String)

Function

©2000MicrosoftCorporation

JScript

length(String)

String

strVariable.length"StringLiteral".length

length String String length-1

1

lengthArray |lengthFunction |String|String

String

©2000MicrosoftCorporation

JScript

LN10

10

numVar=Math.LN10

LN102.302

1

Math

Math

©2000MicrosoftCorporation

JScript

LN2

2

numVar=Math.LN2

LN20.693

1

Math

Math

©2000MicrosoftCorporation

JScript

LOG10E

10 e

varName=Math.LOG10E

LOG10E0.434

1

Math

Math

©2000MicrosoftCorporation

JScript

LOG2E

2 e

varName=Math.LOG2E

LOG2E1.442

1

Math

Math

©2000MicrosoftCorporation

JScript

MAX_VALUE

JScript1.79E+308

number.MAX_VALUE

number Number.

MAX_VALUE Number

2

MIN_VALUE|NaN|NEGATIVE_INFINITY|POSITIVE_INFINITY|toString

Number

©2000MicrosoftCorporation

JScript

message

errorObj.message

errorObjError

message description

TypeError

try{//'null'null.doSomething();}catch(e){print(e.name+":"+e.message);print(e.number+":"+e.description);}

5

description|name

Error

©2000MicrosoftCorporation

JScript

MIN_VALUE

JScript2.22E-308

number.MIN_VALUE

number Number.

MIN_VALUE Number

2

MAX_VALUE|NaN|NEGATIVE_INFINITY|POSITIVE_INFINITY|toString

Number

©2000MicrosoftCorporation

JScript

multiline

Booleanmultiline( m) false

rgExp.multiline

rgExp RegExp

multiline multiline true false m multiline true

multiline false"^""$" multline true"^""\n""\r""$""\n""\r"

multiline"m""while""and"multiline"while"multiline

gi m

functionRegExpPropDemo(flag){if(flag.match(/[^gim]/))//return("Flagspecifiedisnotvalid");varr,re,s//varss="Themanhittheballwiththebat.";ss+="\nwhilethefieldercaughttheballwiththeglove.";re=newRegExp("^while",flag);//r=ss.replace(re,"and");//"a" "the"s="RegularExpressionpropertyvalues:\n\n"s+="globalignoreCasemultiline\n"if(re.global)// global

s+="True";elses+="False";if(re.ignoreCase)// ignoreCases+="True";elses+="False";if(re.multiline)// multilines+="True";elses+="False";s+="\n\nTheresultingstringis:\n\n"+r;return(s);//}

5.5

global|ignoreCase|

RegExp

©2000MicrosoftCorporation

JScript

name

errorObj.name

errorObjError

name

ConversionErrorRangeError ArrayReferenceError nullRegExpError igmSyntaxError evalTypeErrorURIError (URI)

TypeError

try{//'null'null.doSomething();}catch(e){print(e.name+":"+e.message);

print(e.number+":"+e.description);}

5.5

description |message|number

Error

©2000MicrosoftCorporation

JScript

NaN

number.NaN

numberNumber.

NaN Number

NaN NaN isNaN

2

isNaN|MAX_VALUE|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY|toString

Number

©2000MicrosoftCorporation

JScript

NaN(Global)

NaN

NaN

NaN GlobalScripting

3

isNaN

Global

©2000MicrosoftCorporation

JScript

NEGATIVE_INFINITY

JScript -Number.MAX_VALUE

number.NEGATIVE_INFINITY

number Number.

NEGATIVE_INFINITYNumber

JScript NEGATIVE_INFINITY-infinity

2

MAX_VALUE|MIN_VALUE|NaN|POSITIVE_INFINITY|toString

Number

©2000MicrosoftCorporation

JScript

number

Error number

object.number[=errorNumber]

object Error

errorNumber

3216

number

tryx=y//catch(vare){// edocument.write(e)// "[objectError]".document.write(e.number>>16&0x1FFF)//document.write(e.number&0xFFFF)// 5009document.write(e.description)// "'y'isundefined".}

5

description|message|name

Error

©2000MicrosoftCorporation

JScript

PI

3.141592653589793

numVar=Math.PI

PI3.14159.

1

Math

Math

©2000MicrosoftCorporation

JScript

POSITIVE_INFINITY

JScript( Number.MAX_VALUE)

Number.POSITIVE_INFINITY

number Number.

POSITIVE_INFINITYNumber

JScript POSITIVE_INFINITYinfinity

2

MAX_VALUE|MIN_VALUE|NaN|NEGATIVE_INFINITY|toString

Number

©2000MicrosoftCorporation

JScript

propertyIsEnumerable

Boolean

object.propertyIsEnumerable(proName)

object

proName

proName object For…In propertyIsEnumerable true object propertyIsEnumerable false

propertyIsEnumerable

functiontestIsEnumerable(){vara=newArray("apple","banana","cactus");return(a.propertyIsEnumerable(1));}

5.5

Object

©2000MicrosoftCorporation

JScript

prototype

objectName.prototype

objectName

prototype“”

Array Array.prototype

functionarray_max(){vari,max=this[0];for(i=1;i<this.length;i++){if(max<this[i])max=this[i];}returnmax;}Array.prototype.max=array_max;varx=newArray(1,2,3,4,5,6);vary=x.max();

y x6

JScript prototype

2

constructor

Array|Boolean|Date|Function|Number|Object|String

©2000MicrosoftCorporation

JScript

source

rgExp.source

rgExp

source

functionSourceDemo(re,s){vars1;//if(re.test(s))s1="contains";elses1="doesnotcontain";//return(s+s1+re.source);}

3

||

©2000MicrosoftCorporation

JScript

SQRT1_2

0.52

numVar=Math.SQRT1_2

SQRT1_20.707.

1

Math|sqrt|SQRT2

Math

©2000MicrosoftCorporation

JScript

SQRT2

2

numVar=Math.SQRT2

SQRT21.414.

1

Math|sqrt|SQRT1_2

Math

©2000MicrosoftCorporation

JScript

undefined

undefined

undefined

undefined Global undefined

undefined"undefined"

undefined undefined

vardeclared;//if(declared==undefined)//document.write("declaredhasnotbeengivenavalue.");

if(typeOf(notDeclared)=="undefined")document.write("notDeclaredhasnotbeendefined.");

5.5

GlobalObject

©2000MicrosoftCorporation

JScript

JScript

label break

try catch@cc_on

JScript //JScript /*..*/

continue false do...while true for

for...infunction@ifif...elseLabeledreturn@setswitchthis

try...catch throw

JScript tryvar

false whilewith

©2000MicrosoftCorporation

JScript

@cc_on

@cc_on

@cc_onscripting

@cc_on

/*@cc_on*/...

@if @set

3

||@if|@set

©2000MicrosoftCorporation

JScript

@if

@if(condition1)text1[@elif(condition2)text2][@elsetext3]@end

condition1,condition2Boolean

text1condition1 true

text2condition1 false condition2 true

text3condition1 condition2 false

@if @elif @elif @else

@if

alert(@if(@_win32)"usingWindowsNTorWindows95"

3

||@cc_on|@set

©2000MicrosoftCorporation

JScript

@set

@set@varname=term

varnameJScript"@"

term

Boolean @setJScript

@set@myvar1=12

@set@myvar2=(@myvar1*20)

@set@myvar3=@_jscript_version

!~

*/%

+-

<<>>>>>

<<=>>=

==!====!==

&^|

&&||

NaNNaN @if

@if(@newVar!=@newVar)...

NaN

3

||@cc_on|@if

©2000MicrosoftCorporation

JScript

break

label

break[label];

label

switch whileforfor...in do...while break switchlabel

break

break

functionBreakTest(breakpoint){vari=0;while(i<100){if(i==breakpoint)break;i++;}return(i);}

1

continue|do...while|for|for...in|Labeled|while

©2000MicrosoftCorporation

JScript

Comment

JScript

1

//comment

2

/*comment*/

comment

3//@CondStatement

4/*@condStatement@*/

condStatement3"//""@"

JScript

12

3412

comment

functionmyfunction(arg1,arg2){/* */varr;//r=arg1+arg2;//return(r);}

1

©2000MicrosoftCorporation

JScript

continue

continue[label];

label continue

whiledo...whilefor for...in continue continue

while do...whiletrue

fortrue

for...in

continue

functionskip5(){vars="",i=0;while(i<10){i++;// 5if(i==5){continue;}s+=i;}

return(s);}

1

break|do...while|for|for...in|Labeled|while

©2000MicrosoftCorporation

JScript

do...while

false

dostatementwhile(expression);

statementexpression true

expressionBoolean true false expression true expression false

expression

do...while Drives

functionGetDriveList(){varfso,s,n,e,x;fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);s="";do{x=e.item();

s=s+x.DriveLetter;s+="-";if(x.DriveType==3)n=x.ShareName;elseif(x.IsReady)n=x.VolumeName;elsen="[Drivenotready]";s+=n+"<br>";e.moveNext();}while(!e.atEnd());return(s);}

3

break|continue|for|for...in|while|Labeled

©2000MicrosoftCorporation

JScript

for

true

for(initialization;test;increment)statements

initialization

testBoolean test true statement test false

increment

statementstest true

for

for

/* i 0 1

i 10 */varmyarray=newArray();

for(i=0;i<10;i++){myarray[i]=i;}

1

for...in|while

©2000MicrosoftCorporation

JScript

for...in

for(variablein[object|array])statements

variable object array

object,array

statement object array

variable object array object array

variable012......

for...in

functionForInDemo(){//vara,key,s="";//a={"a":"Athens","b":"Belgrade","c":"Cairo"}

//for(keyina){s+=a[key]+"&ltBR>";}return(s);}

5

enumerator

for|while

©2000MicrosoftCorporation

JScript

function

functionfunctionname([arg1[,arg2[,...[,argN]]]]){statements}

functionname

arg1...argN

statementsJScript

function statements

function

functionmyfunction(arg1,arg2){varr;r=arg1*arg2;return(r);}

1

new

©2000MicrosoftCorporation

JScript

if...else

if(condition)statement1[elsestatement2]

condition Boolean condition nullundefined condition false

statement1condition true

statement2condition false

statement1 statement2({})

else if

if(x==5)if(y==6)z=17;elsez=20;

if(x==5){if(y==6)z=17;}elsez=20;

statement1

if(x==5)z=7;q=42;elsez=19;

if else if else

1

(?:)

©2000MicrosoftCorporation

JScript

Labeled

label:statements

label

statement label

break continue break continue

continue labeled

functionlabelDemo(){vara=newArray();vari,j,s="",s1="";Outer:for(i=0;i<5;i++){Inner:for(j=0;j<5;j++){

if(j==2)continueInner;elsea[i,j]=j+1;}}for(i=0;i<5;i++){s=""for(j=0;j<5;j++){s+=a[i,j];}s1+=s+"\n";}return(s1)}

3

break|continue

©2000MicrosoftCorporation

JScript

return

return[()[expression][]];

expression

return expression expression returnundefined

return

functionmyfunction(arg1,arg2){varr;r=arg1*arg2;return(r);}

1

function

©2000MicrosoftCorporation

JScript

switch

switch(expression){caselabel:statementlistcaselabel:statementlist...default:statementlist}

expression

label expression label===expression statementlist break switch

statementlist

default expression switch

label label expression default

switch

expression label

label expression statementlist break switch break label

label expression default default

switch

functionMyObject(){...}

switch(object.constructor){caseDate:...caseNumber:...caseString:...caseMyObject:...default:...}

3

break|if...else

©2000MicrosoftCorporation

JScript

this

this.property

property

this

thisCar

functionCar(color,make,model){this.color=color;this.make=make;this.model=model;}

JScript this window

1

new

©2000MicrosoftCorporation

JScript

throw

try...catch...finally

throwexception

exception

try...catch...finally

functionTryCatchDemo(x){try{try{if(x==0)//throw"xequalszero";//elsethrow"xdoesnotequalzero";//}catch(e){// "x=0"if(e=="xequalszero")//return(e+"handledlocally.");//else//throwe;//}//}catch(e){//return(e+"handledhigherup.");//}}

document.write(TryCatchDemo(0));document.write(TryCatchDemo(1));

5

try...catch

©2000MicrosoftCorporation

JScript

try...catch...finally

JScript

try{tryStatements}catch(exception){catchStatements}finally{finallyStatements}

tryStatement

exceptionexception

catchStatement tryStatement

finallyStatements

try...catch...finallyJScript

tryStatements catchStatement tryStatementscatchStatements exception tryStatements catchStatements

tryStatements catchStatements throw

tryStatements catchStatements finallyStatements

try catch catch finallyStatements

finallyStatments catch

JScript

try{print("Outertryrunning..");try{print("Nestedtryrunning...");throw"anerror";}catch(e){print("Nestedcatchcaught"+e);throwe+"re-thrown";}finally{print("Nestedfinallyisrunning...");}}catch(e){print("Outercatchcaught"+e);}finally{print("Outerfinallyrunning");}//WindowsScriptHost WScript.Echo(s)functionprint(s){document.write(s);

}

Outertryrunning..Nestedtryrunning...NestedcatchcaughtanerrorNestedfinallyisrunning...Outercatchcaughtanerrorre-thrownOuterfinallyrunning

5

throw

©2000MicrosoftCorporation

JScript

var

varvariable1[=value1][,variable2[=value2],...]

variable,variable2

value,value2

var

var

varindex;varname="ThomasJefferson";varanswer=42,counter,numpages=10;

1

function|new

©2000MicrosoftCorporation

JScript

while

false

while(expression)statements

expressionBoolean expression true expression false

statementsexpression true

while expression expression false

while

functionBreakTest(breakpoint){vari=0;while(i<100){if(i==breakpoint)break;i++;}return(i);

}

1

break|continue|do...while|for|for...in

©2000MicrosoftCorporation

JScript

with

with(object)statements

object

statementsobject

with Math

x=Math.cos(3*Math.PI)+Math.sin(Math.LN10)y=Math.tan(14*Math.E)

with

with(Math){x=cos(3*PI)+sin(LN10)y=tan(14*E)}

1

this

©2000MicrosoftCorporation

JScript

FileSystemObject

FileSystemObject

FileSystemObjectScripting

FileSystemObject

FileSystemObject

FileSystemObject

©2000MicrosoftCorporation

JScript

FileSystemObject

ActiveServerPagesWindowsScriptingHostscriptingWebWeb

Scripting FileSystemObject(FSO)

FileSystemObjectScripting

FileSystemObject

FileSystemObject

FileSystemObject

©2000MicrosoftCorporation

JScript

FileSystemObjectScripting

FileSystemObject(FSO) object.method

HTMLWeb

WindowsScriptingHostMicrosoftWindows

ScriptControl

FSOFSOInternetWebInternetExplorerFileSystemObject

FSO

FSOAccessSQL

Scripting(Scrrun.dll)FSO TextStream

©2000MicrosoftCorporation

JScript

FileSystemObject

FileSystemObject(FSO)

/FileSystemObject FSO

Drive "drive"CD-ROMRAM

Drives DrivesFileFilesFolderFolders FolderTextStream

©2000MicrosoftCorporation

JScript

FileSystemObject

FileSystemObject(FSO)

CreateObjectFileSystemObject

FSOScriptingScrrun.dllFSOScrrun.dllWeb

FileSystemObject

CreateObject FileSystemObjectVBScriptFileSystemObject

DimfsoSetfso=CreateObject("Scripting.FileSystemObject")

FileSystemObject

JScript

varfso;fso=newActiveXObject("Scripting.FileSystemObject");

Scripting FileSystemObject FileSystemObject

FileSystemObject CreateTextFile CreateFolderFSO

FileSystemObject DeleteFile DeleteFolder FileFolder Delete

FileSystemObject FileSystemObject CopyFileFile Copy

FileSystemObject"get"

GetDrive

GetFolder

GetFile

VBScript

Dimfso,f1Setfso=CreateObject("Scripting.FileSystemObject")Setf1=fso.GetFile("c:\test.txt")

JScript

varfso,f1;fso=newActiveXObject("Scripting.FileSystemObject");f1=fso.GetFile("c:\\test.txt");

"get""create" CreateFolder GetFolderNamePathSize CreateFolderVBScript

SubCreateFolderDimfso,fldrSetfso=CreateObject("Scripting.FileSystemObject")Setfldr=fso.CreateFolder("C:\MyTest")Response.Write"Createdfolder:"&fldr.NameEndSub

JScript CreateFolder

functionCreateFolder()

{varfso,fldr;fso=newActiveXObject("Scripting.FileSystemObject");fldr=fso.CreateFolder("C:\\MyTest");Response.Write("Createdfolder:"+fldr.Name);}

GetFolder

VBScript GetFolder

Setfldr=fso.GetFolder("c:\")

JScript

varfldr=fso.GetFolder("c:\\");

Folder NameVBScript

Response.Write"Foldernameis:"&fldr.Name

JScript Name

Response.Write("Foldernameis:"+fldr.Name);

VBScript

Dimfso,f1Setfso=CreateObject("Scripting.FileSystemObject")'Setf1=fso.GetFile("c:\detlog.txt")'Response.Write"Filelastmodified:"&f1.DateLastModified

JScript

varfso,f1;fso=newActiveXObject("Scripting.FileSystemObject");//

f1=fso.GetFile("c:\\detlog.txt");//Response.Write("Filelastmodified:"+f1.DateLastModified);

©2000MicrosoftCorporation

JScript

FileSystemObject(FSO)Windows

Drive

TotalSize

AvailableSpace FreeSpace

DriveLetter

CD-ROMRAM DriveType

SerialNumber

FATFAT32NTFS FileSystem

IsReady

/ShareNameVolumeName

Path RootFolder

FileSystemObject

Drive Drive Drive GetDrive Drivedrv

VBScript Drive

SubShowDriveInfo(drvPath)Dimfso,drv,sSetfso=CreateObject("Scripting.FileSystemObject")Setdrv=fso.GetDrive(fso.GetDriveName(drvPath))s="Drive"&UCase(drvPath)&"-"s=s&drv.VolumeName&"<br>"s=s&"TotalSpace:"&FormatNumber(drv.TotalSize/1024,0)s=s&"Kb"&"<br>"s=s&"FreeSpace:"&FormatNumber(drv.FreeSpace/1024,0)

s=s&"Kb"&"<br>"Response.WritesEndSubJScript

functionShowDriveInfo1(drvPath){varfso,drv,s="";fso=newActiveXObject("Scripting.FileSystemObject");drv=fso.GetDrive(fso.GetDriveName(drvPath));s+="Drive"+drvPath.toUpperCase()+"-";s+=drv.VolumeName+"<br>";s+="TotalSpace:"+drv.TotalSize/1024;s+="Kb"+"<br>";s+="FreeSpace:"+drv.FreeSpace/1024;s+="Kb"+"<br>";Response.Write(s);}

FileSystemObject.CreateFolderFolder.DeleteFileSystemObject.DeleteFolderFolder.MoveFileSystemObject.MoveFolderFolder.CopyFileSystemObject.CopyFolderFolder.NameFileSystemObject.FolderExists

Folder FileSystemObject.GetFolderFileSystemObject.GetParentFolderNameFileSystemObject.GetSpecialFolder

FileSystemObject

VBScript Folder FileSystemObject

SubShowFolderInfo()Dimfso,fldr,s' FileSystemObjectSetfso=CreateObject("Scripting.FileSystemObject")' DriveSetfldr=fso.GetFolder("c:")'Response.Write"Parentfoldernameis:"&fldr&"<br>"'Response.Write"Containedondrive"&fldr.Drive&"<br>"'Iffldr.IsRootFolder=TrueThenResponse.Write"Thisistherootfolder."&""<br>"<br>"

ElseResponse.Write"Thisfolderisn'tarootfolder."&"<br><br>"EndIf'FileSystemObjectfso.CreateFolder("C:\Bogus")Response.Write"CreatedfolderC:\Bogus"&"<br>"'Response.Write"Basename="&fso.GetBaseName("c:\bogus")&"<br>"'fso.DeleteFolder("C:\Bogus")Response.Write"DeletedfolderC:\Bogus"&"<br>"EndSubJScript Folder FileSystemObject

functionShowFolderInfo(){varfso,fldr,s="";// FileSystemObjectfso=newActiveXObject("Scripting.FileSystemObject");// Drivefldr=fso.GetFolder("c:");//Response.Write("Parentfoldernameis:"+fldr+"<br>");//Response.Write("Containedondrive"+fldr.Drive+"<br>");//if(fldr.IsRootFolder)Response.Write("Thisistherootfolder.");

elseResponse.Write("Thisfolderisn'tarootfolder.");Response.Write("<br><br>");//FileSystemObjectfso.CreateFolder("C:\\Bogus");Response.Write("CreatedfolderC:\\Bogus"+"<br>");//Response.Write("Basename="+fso.GetBaseName("c:\\bogus")+"<br>");//fso.DeleteFolder("C:\\Bogus");Response.Write("DeletedfolderC:\\Bogus"+"<br>");}

©2000MicrosoftCorporation

JScript

“”

CreateTextFileVBScript

Dimfso,f1Setfso=CreateObject("Scripting.FileSystemObject")Setf1=fso.CreateTextFile("c:\testfile.txt",True)

JScript

varfso,f1;fso=newActiveXObject("Scripting.FileSystemObject");f1=fso.CreateTextFile("c:\\testfile.txt",true);

FileSystemObject OpenTextFile ForWritingVBScript

Dimfso,tsConstForWriting=2Setfso=CreateObject("Scripting.FileSystemObject")Setts=fso.OpenTextFile("c:\test.txt",ForWriting,True)

JScript

varfso,ts;varForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");ts=fso.OpenTextFile("c:\\test.txt",ForWriting,true);

OpenAsTextStream ForWritingVBScript

Dimfso,f1,tsConstForWriting=2Setfso=CreateObject("Scripting.FileSystemObject")fso.CreateTextFile("c:\test1.txt")Setf1=fso.GetFile("c:\test1.txt")Setts=f1.OpenAsTextStream(ForWriting,True)

JScript

varfso,f1,ts;varForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");fso.CreateTextFile("c:\\test1.txt");f1=fso.GetFile("c:\\test1.txt");ts=f1.OpenAsTextStream(ForWriting,true);

FileSystemObjectOpenTextFileFileOpenAsTextStream

TextStreamWriteWriteLineWriteBlankLines

WriteWriteLineWriteBlankLines

TextStream Close

/

VBScript

SubCreateFile()Dimfso,tfSetfso=CreateObject("Scripting.FileSystemObject")Settf=fso.CreateTextFile("c:\testfile.txt",True)'tf.WriteLine("Testing1,2,3.")' tf.WriteBlankLines(3)'

tf.Write("Thisisatest.")tf.CloseEndSubJScript

functionCreateFile(){varfso,tf;fso=newActiveXObject("Scripting.FileSystemObject");tf=fso.CreateTextFile("c:\\testfile.txt",true);//tf.WriteLine("Testing1,2,3.");// tf.WriteBlankLines(3);//tf.Write("Thisisatest.");tf.Close();}

TextStream ReadReadLine ReadAll

ReadReadLineReadAll

Read ReadLine Skip SkipLinereadLeftRight Mid

VBScript

SubReadFilesDimfso,f1,ts,sConstForReading=1Setfso=CreateObject("Scripting.FileSystemObject")Setf1=fso.CreateTextFile("c:\testfile.txt",True)'Response.Write"Writingfile<br>"f1.WriteLine"HelloWorld"f1.WriteBlankLines(1)f1.Close'Response.Write"Readingfile<br>"Setts=fso.OpenTextFile("c:\testfile.txt",ForReading)s=ts.ReadLineResponse.Write"Filecontents='"&s&"'"ts.Close

EndSubJScript

functionReadFiles(){varfso,f1,ts,s;varForReading=1;fso=newActiveXObject("Scripting.FileSystemObject");f1=fso.CreateTextFile("c:\\testfile.txt",true);//Response.Write("Writingfile<br>");f1.WriteLine("HelloWorld");f1.WriteBlankLines(1);f1.Close();//Response.Write("Readingfile<br>");ts=fso.OpenTextFile("c:\\testfile.txt",ForReading);s=ts.ReadLine();Response.Write("Filecontents='"+s+"'");ts.Close();}

FSO

File.MoveFileSystemObject.MoveFileFile.CopyFileSystemObject.CopyFileFile.DeleteFileSystemObject.DeleteFile

VBScriptC\tmp\temp

C\tmp\temp

SubManipFilesDimfso,f1,f2,sSetfso=CreateObject("Scripting.FileSystemObject")Setf1=fso.CreateTextFile("c:\testfile.txt",True)Response.Write"Writingfile<br>"'f1.Write("Thisisatest.")'f1.CloseResponse.Write"Movingfiletoc:\tmp<br>"' C (C:\)Setf2=fso.GetFile("c:\testfile.txt")' \tmpf2.Move("c:\tmp\testfile.txt")Response.Write"Copyingfiletoc:\temp<br>"' \temp

f2.Copy("c:\temp\testfile.txt")Response.Write"Deletingfiles<br>"'Setf2=fso.GetFile("c:\tmp\testfile.txt")Setf3=fso.GetFile("c:\temp\testfile.txt")'f2.Deletef3.DeleteResponse.Write"Alldone!"EndSubJScript

functionManipFiles(){varfso,f1,f2,s;fso=newActiveXObject("Scripting.FileSystemObject");f1=fso.CreateTextFile("c:\\testfile.txt",true);Response.Write("Writingfile<br>");//f1.Write("Thisisatest.");//f1.Close();Response.Write("Movingfiletoc:\\tmp<br>");// C (C:\)f2=fso.GetFile("c:\\testfile.txt");// \tmpf2.Move("c:\\tmp\\testfile.txt");Response.Write("Copyingfiletoc:\\temp<br>");

// \tempf2.Copy("c:\\temp\\testfile.txt");Response.Write("Deletingfiles<br>");//f2=fso.GetFile("c:\\tmp\\testfile.txt");f3=fso.GetFile("c:\\temp\\testfile.txt");//f2.Delete();f3.Delete();Response.Write("Alldone!");}

©2000MicrosoftCorporation

JScript

FileSystemObject

FileSystemObject

ActiveServerPagesWindowsScriptingHost

ActiveServerPages

Web.asp

&ltBODY>...</BODY>

<%...%>

OptionExplicitHTML<HTML>

<%...%> OptionExplicit

SubPrint(x)Response.Write"<PRE>&ltFONTFACE="" ""SIZE=""1"">"Response.WritexResponse.Write"</FONT></PRE>"EndSubMain

WindowsScriptingHost

SubPrint(x)WScript.EchoxEndSubMain

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''FileSystemObject'Copyright1998MicrosoftCorporation ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

OptionExplicit

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1) "&"''''''2) "OptionExplicit"' DriveTypeCDROM' DriveTypeCDORM''3)''OnErrorResumeNextErr''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''DimTabStop

DimNewLine

ConstTestDrive="C"ConstTestFilePath="C:\Test"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Drive.DriveType''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ConstDriveTypeRemovable=1ConstDriveTypeFixed=2ConstDriveTypeNetwork=3ConstDriveTypeCDROM=4ConstDriveTypeRAMDisk=5

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''File.Attributes''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ConstFileAttrNormal=0ConstFileAttrReadOnly=1ConstFileAttrHidden=2ConstFileAttrSystem=4ConstFileAttrVolume=8ConstFileAttrDirectory=16ConstFileAttrArchive=32ConstFileAttrAlias=64ConstFileAttrCompressed=128

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ConstOpenFileForReading=1ConstOpenFileForWriting=2ConstOpenFileForAppending=8

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ShowDriveType' ' Drive''-Drive.DriveType''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''FunctionShowDriveType(Drive)

DimSSelectCaseDrive.DriveTypeCaseDriveTypeRemovableS="Removable"CaseDriveTypeFixedS="Fixed"CaseDriveTypeNetworkS="Network"CaseDriveTypeCDROMS="CD-ROM"CaseDriveTypeRAMDiskS="RAMDisk"CaseElse

S="Unknown"EndSelect

ShowDriveType=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ShowFileAttr' '''-File.Attributes'-Folder.Attributes''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionShowFileAttr(File)'File

DimSDimAttrAttr=File.Attributes

IfAttr=0ThenShowFileAttr="Normal"ExitFunctionEndIf

IfAttrAndFileAttrDirectoryThenS=S&"Directory"IfAttrAndFileAttrReadOnlyThenS=S&"Read-Only"

IfAttrAndFileAttrHiddenThenS=S&"Hidden"IfAttrAndFileAttrSystemThenS=S&"System"IfAttrAndFileAttrVolumeThenS=S&"Volume"IfAttrAndFileAttrArchiveThenS=S&"Archive"IfAttrAndFileAttrAliasThenS=S&"Alias"IfAttrAndFileAttrCompressedThenS=S&"Compressed"

ShowFileAttr=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GenerateDriveInformation' '''-FileSystemObject.Drives'-IteratingtheDrivescollection'-Drives.Count'-Drive.AvailableSpace'-Drive.DriveLetter'-Drive.DriveType'-Drive.FileSystem'-Drive.FreeSpace'-Drive.IsReady'-Drive.Path'-Drive.SerialNumber'-Drive.ShareName

'-Drive.TotalSize'-Drive.VolumeName''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGenerateDriveInformation(FSO)

DimDrivesDimDriveDimS

SetDrives=FSO.DrivesS="Numberofdrives:"&TabStop&Drives.Count&NewLine&NewLine

'S=S&String(2,TabStop)&"Drive"S=S&String(3,TabStop)&"File"S=S&TabStop&"Total"S=S&TabStop&"Free"S=S&TabStop&"Available"S=S&TabStop&"Serial"&NewLine

'S=S&"Letter"S=S&TabStop&"Path"S=S&TabStop&"Type"S=S&TabStop&"Ready?"S=S&TabStop&"Name"S=S&TabStop&"System"S=S&TabStop&"Space"

S=S&TabStop&"Space"S=S&TabStop&"Space"S=S&TabStop&"Number"&NewLine

'S=S&String(105,"-")&NewLine

ForEachDriveInDrivesS=S&Drive.DriveLetterS=S&TabStop&Drive.PathS=S&TabStop&ShowDriveType(Drive)S=S&TabStop&Drive.IsReady

IfDrive.IsReadyThenIfDriveTypeNetwork=Drive.DriveTypeThenS=S&TabStop&Drive.ShareNameElseS=S&TabStop&Drive.VolumeNameEndIfS=S&TabStop&Drive.FileSystemS=S&TabStop&Drive.TotalSizeS=S&TabStop&Drive.FreeSpaceS=S&TabStop&Drive.AvailableSpaceS=S&TabStop&Hex(Drive.SerialNumber)EndIf

S=S&NewLine

Next

GenerateDriveInformation=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GenerateFileInformation' '''-File.Path'-File.Name'-File.Type'-File.DateCreated'-File.DateLastAccessed'-File.DateLastModified'-File.Size''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGenerateFileInformation(File)

DimS

S=NewLine&"Path:"&TabStop&File.PathS=S&NewLine&"Name:"&TabStop&File.NameS=S&NewLine&"Type:"&TabStop&File.TypeS=S&NewLine&"Attribs:"&TabStop&ShowFileAttr(File)S=S&NewLine&"Created:"&TabStop&File.DateCreatedS=S&NewLine&"Accessed:"&TabStop&File.DateLastAccessed

S=S&NewLine&"Modified:"&TabStop&File.DateLastModifiedS=S&NewLine&"Size"&TabStop&File.Size&NewLine

GenerateFileInformation=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GenerateFolderInformation' '''-Folder.Path'-Folder.Name'-Folder.DateCreated'-Folder.DateLastAccessed'-Folder.DateLastModified'-Folder.Size''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGenerateFolderInformation(Folder)

DimS

S="Path:"&TabStop&Folder.PathS=S&NewLine&"Name:"&TabStop&Folder.NameS=S&NewLine&"Attribs:"&TabStop&ShowFileAttr(Folder)S=S&NewLine&"Created:"&TabStop&Folder.DateCreatedS=S&NewLine&"Accessed:"&TabStop&Folder.DateLastAccessed

S=S&NewLine&"Modified:"&TabStop&Folder.DateLastModifiedS=S&NewLine&"Size:"&TabStop&Folder.Size&NewLine

GenerateFolderInformation=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GenerateAllFolderInformation' '''-Folder.Path'-Folder.SubFolders'-Folders.Count''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGenerateAllFolderInformation(Folder)

DimSDimSubFoldersDimSubFolderDimFilesDimFile

S="Folder:"&TabStop&Folder.Path&NewLine&NewLineSetFiles=Folder.Files

If1=Files.CountThenS=S&"Thereis1file"&NewLine

ElseS=S&"Thereare"&Files.Count&"files"&NewLineEndIf

IfFiles.Count<>0ThenForEachFileInFilesS=S&GenerateFileInformation(File)NextEndIf

SetSubFolders=Folder.SubFolders

If1=SubFolders.CountThenS=S&NewLine&"Thereis1subfolder"&NewLine&NewLineElseS=S&NewLine&"Thereare"&SubFolders.Count&"subfolders"&NewLine&NewLineEndIf

IfSubFolders.Count<>0ThenForEachSubFolderInSubFoldersS=S&GenerateFolderInformation(SubFolder)NextS=S&NewLineForEachSubFolderInSubFoldersS=S&GenerateAllFolderInformation(SubFolder)NextEndIf

GenerateAllFolderInformation=S

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GenerateTestInformation' ' C:\Test''-FileSystemObject.DriveExists'-FileSystemObject.FolderExists'-FileSystemObject.GetFolder''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGenerateTestInformation(FSO)

DimTestFolderDimS

IfNotFSO.DriveExists(TestDrive)ThenExitFunctionIfNotFSO.FolderExists(TestFilePath)ThenExitFunction

SetTestFolder=FSO.GetFolder(TestFilePath)

GenerateTestInformation=GenerateAllFolderInformation(TestFolder)

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''DeleteTestDirectory'

' test''-FileSystemObject.GetFolder'-FileSystemObject.DeleteFile'-FileSystemObject.DeleteFolder'-Folder.Delete'-File.Delete''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SubDeleteTestDirectory(FSO)

DimTestFolderDimSubFolderDimFile

'

FSO.DeleteFile(TestFilePath&"\Beatles\OctopusGarden.txt")

SetFile=FSO.GetFile(TestFilePath&"\Beatles\BathroomWindow.txt")File.Delete

'FSO.DeleteFolder(TestFilePath&"\Beatles")FSO.DeleteFile(TestFilePath&"\ReadMe.txt")SetTestFolder=FSO.GetFolder(TestFilePath)TestFolder.Delete

EndSub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''CreateLyrics' '''-FileSystemObject.CreateTextFile'-TextStream.WriteLine'-TextStream.Write'-TextStream.WriteBlankLines'-TextStream.Close''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SubCreateLyrics(Folder)

DimTextStream

SetTextStream=Folder.CreateTextFile("OctopusGarden.txt")

TextStream.Write("Octopus'Garden")'TextStream.WriteLine("(byRingoStarr)")TextStream.WriteBlankLines(1)TextStream.WriteLine("I'dliketobeundertheseainanoctopus'gardenintheshade,")TextStream.WriteLine("He'dletusin,knowswherewe'vebeen--inhisoctopus'gardenintheshade.")TextStream.WriteBlankLines(2)TextStream.Close

SetTextStream=Folder.CreateTextFile("BathroomWindow.txt")TextStream.WriteLine("SheCameInThroughTheBathroomWindow(byLennon/McCartney)")TextStream.WriteLine("")TextStream.WriteLine("Shecameinthroughthebathroomwindowprotectedbyasilverspoon")TextStream.WriteLine("Butnowshesucksherthumbandwandersbythebanksofherownlagoon")TextStream.WriteBlankLines(2)TextStream.Close

EndSub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''GetLyrics' ' lyrics''-FileSystemObject.OpenTextFile'-FileSystemObject.GetFile'-TextStream.ReadAll'-TextStream.Close'-File.OpenAsTextStream'-TextStream.AtEndOfStream'-TextStream.ReadLine''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionGetLyrics(FSO)

DimTextStreamDimSDimFile

''

SetTextStream=FSO.OpenTextFile(TestFilePath&"\Beatles\OctopusGarden.txt",OpenFileForReading)

S=TextStream.ReadAll&NewLine&NewLineTextStream.Close

SetFile=FSO.GetFile(TestFilePath&"\Beatles\BathroomWindow.txt")SetTextStream=File.OpenAsTextStream(OpenFileForReading)DoWhileNotTextStream.AtEndOfStreamS=S&TextStream.ReadLine&NewLineLoopTextStream.Close

GetLyrics=SEndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''BuildTestDirectory' ' FileSystemObject''C:\Test'C:\Test\ReadMe.txt'C:\Test\Beatles'C:\Test\Beatles\OctopusGarden.txt

'C:\Test\Beatles\BathroomWindow.txt''-FileSystemObject.DriveExists'-FileSystemObject.FolderExists'-FileSystemObject.CreateFolder'-FileSystemObject.CreateTextFile'-Folders.Add'-Folder.CreateTextFile'-TextStream.WriteLine'-TextStream.Close''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

FunctionBuildTestDirectory(FSO)

DimTestFolderDimSubFoldersDimSubFolderDimTextStream' (a) (b)

IfNotFSO.DriveExists(TestDrive)ThenBuildTestDirectory=FalseExitFunctionEndIf

IfFSO.FolderExists(TestFilePath)ThenBuildTestDirectory=FalseExitFunctionEndIf

SetTestFolder=FSO.CreateFolder(TestFilePath)

SetTextStream=FSO.CreateTextFile(TestFilePath&"\ReadMe.txt")TextStream.WriteLine("Mysonglyricscollection")TextStream.Close

SetSubFolders=TestFolder.SubFoldersSetSubFolder=SubFolders.Add("Beatles")CreateLyricsSubFolderBuildTestDirectory=True

EndFunction

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' test ' test' test''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SubMain

DimFSO

'TabStop=Chr(9)NewLine=Chr(10)

SetFSO=CreateObject("Scripting.FileSystemObject")

IfNotBuildTestDirectory(FSO)ThenPrint"Testdirectoryalreadyexistsorcannotbecreated.Cannotcontinue."ExitSubEndIf

PrintGenerateDriveInformation(FSO)&NewLine&NewLinePrintGenerateTestInformation(FSO)&NewLine&NewLinePrintGetLyrics(FSO)&NewLine&NewLineDeleteTestDirectory(FSO)

EndSub

©2000MicrosoftCorporation

JScript

Script

Dictionary AddDictionaryFoldersFolder AddFolders

BuildPathTextStream Close

CopyCopyFileCopyFolderCreateFolder

TextStream CreateTextFileDeleteDeleteFileDeleteFolder

TrueFalse DriveExistsDictionaryTrueFalse Exists

TrueFalse FileExistsTrueFalse FolderExists

GetAbsolutePathNameGetBaseName

Drive GetDriveGetDriveNameGetExtensionName

File GetFileGetFileNameGetFileVersion

Folder GetFolderGetParentFolderNameGetSpecialFolderGetTempName

Dictionary ItemsDictionary Keys

MoveMoveFileMoveFolder

TextStream OpenAsTextStreamTextStream OpenTextFileTextStream ReadTextStream ReadAllTextStream ReadLineDictionary RemoveDictionary RemoveAll

TextStream SkipTextStream SkipLineTextStream WriteTextStream WriteBlankLinesTextStream WriteLine

©2000MicrosoftCorporation

JScript

Add(Dictionary)

Dictionary

object.Add(key,item)

object Dictionary

key item key

item key item

key

Add

vard;d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");d.Add("b","Belgrade");d.Add("c","Cairo");

Add(Folders) |Exists|Items|Keys|Remove|RemoveAllDictionary

©2000MicrosoftCorporation

JScript

Add(Folders)

Folders Folder

object.Add(folderName)

object Folders

folderName Folder

Add

functionAddNewFolder(path,folderName){varfso,f,fc,nf;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(path);fc=f.SubFolders;if(folderName!="")nf=fc.Add(folderName);elsenf=fc.Add("NewFolder");}

folderName

Add(Dictionary) Folders

©2000MicrosoftCorporation

JScript

BuildPath

object.BuildPath(path,name)

objectFileSystemObject

path name

name path

BuildPath

BuildPath

functionGetBuildPath(path){varfso,newpath;fso=newActiveXObject("Scripting.FileSystemObject");newpath=fso.BuildPath(path,"NewFolder");return(newpath);}

GetAbsolutePathName|GetBaseName|GetDriveName|GetExtensionName|GetFileName|GetParentFolderName|GetTempName FileSystemObject

©2000MicrosoftCorporation

JScript

Close

TextStream

object.Close();

object TextStream

Close

varfso;fso=newActiveXObject("Scripting.FileSystemObject");a=fso.CreateTextFile("c:\\testfile.txt",true);a.WriteLine("Thisisatest.");a.Close();

©2000MicrosoftCorporation

JScript

Copy

object.Copy(destination[,overwrite]);

object File Folder

destination

overwriteBoolean True False

Copy File Folder FileSystemObject.CopyFileFileSystemObject.CopyFolder object

Copy

varfso,f;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.CreateTextFile("c:\\testfile.txt",true);f.WriteLine("Thisisatest.");f.Close();f=fso.GetFile("c:\\testfile.txt");

f.Copy("c:\\windows\\desktop\\test2.txt");

CopyFile|CopyFolder|Delete|Move|OpenAsTextStreamFile|Folder

©2000MicrosoftCorporation

JScript

CopyFile

object.CopyFile(source,destination[,overwrite])

object object FileSystemObject

source

destination source

overwriteBoolean true false truedestination overwrite CopyFile

source

fso=newActiveXObject("Scripting.FileSystemObject");fso.CopyFile("c:\\mydocuments\\letters\\*.doc","c:\\tempfolder\\")

fso=newActiveXObject("Scripting.FileSystemObject");fso.CopyFile("c:\\mydocuments\\*\\R1???97.xls","c:\\tempfolder")

source destination(\) destination

destination

destination source

destination overwrite false source

destination

source CopyFile

Copy|CopyFolder|CreateTextFile|DeleteFile|MoveFileFileSystemObject

©2000MicrosoftCorporation

JScript

CopyFolder

object.CopyFolder(source,destination[,overwrite]);

objectFileSystemObject

source

destination source

overwriteBoolean true false true

source

fso=newActiveXObject("Scripting.FileSystemObject");fso.CopyFolder("c:\\mydocuments\\letters\\*","c:\\tempfolder\\")

fso=newActiveXObject("Scripting.FileSystemObject");fso.CopyFolder("c:\\mydocuments\\*\\*","c:\\tempfolder\\")

source destination(\) destinationdestination

destination source

destination

destination source destination overwrite false

destination overwrite false

source

CopyFolder

CopyFile|Copy|CreateFolder|DeleteFolder|MoveFolderFileSystemObject

©2000MicrosoftCorporation

JScript

CreateFolder

object.CreateFolder(foldername)

objectFileSystemObject

foldername

CreateFolder

varfso=newActiveXObject("Scripting.FileSystemObject");vara=fso.CreateFolder("c:\\newfolder");

CopyFolder|DeleteFolder|MoveFolder FileSystemObject

©2000MicrosoftCorporation

JScript

CreateTextFile

TextStream

object.CreateTextFile(filename[,overwrite[,unicode]])

objectFileSystemObjectFolder

filename

overwriteBoolean true false

unicodeBooleanUnicodeASCIIUnicode trueASCII falseASCII

CreateTextFile

varfso=newActiveXObject("Scripting.FileSystemObject");vara=fso.CreateTextFile("c:\\testfile.txt",true);a.WriteLine("Thisisatest.");a.Close();

overwrite false filename

CreateFolder|OpenAsTextStream|OpenTextFile FileSystemObject|Folder

©2000MicrosoftCorporation

JScript

Delete

object.Delete(force);

object File Folder

forceBoolean True False

DeleteFileFolderFileSystemObject.DeleteFileFileSystemObject.DeleteFolder

Delete

Delete

varfso,f;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.CreateTextFile("c:\\testfile.txt",true);f.WriteLine("Thisisatest.");f.Close();f=fso.GetFile("c:\\testfile.txt");f.Delete();

Copy|DeleteFile|DeleteFolder|Move|OpenAsTextStreamFile|Folder

©2000MicrosoftCorporation

JScript

DeleteFile

object.DeleteFile(filespec[,force]);

objectFileSystemObject

filespec filespec

forceBoolean true false

DeleteFile

DeleteFile

functionDeleteFile(filespec){varfso;fso=newActiveXObject("Scripting.FileSystemObject");fso.DeleteFile(filespec);}

CopyFile|CreateTextFile|Delete|DeleteFolder|MoveFile

FileSystemObject

©2000MicrosoftCorporation

JScript

DeleteFolder

object.DeleteFolder(folderspec[,force]);

objectFileSystemObject

folderspec folderspec

forceBoolean true false

DeleteFolder

DeleteFolder

DeleteFolder

functionDeleteFolder(folderspec){varfso;fso=newActiveXObject("Scripting.FileSystemObject");fso.DeleteFolder(folderspec);}

CopyFolder|CreateFolder|Delete|DeleteFile|MoveFolderFileSystemObject

©2000MicrosoftCorporation

JScript

DriveExists

True False

object.DriveExists(drivespec)

objectFileSystemObject

drivespec

DriveExists true Drive IsReady

DriveExists

functionReportDriveStatus(drv){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");if(fso.DriveExists(drv))s+="Drive"+drv+"exists.";elses+="Drive"+drv+"doesn'texist.";return(s);}

DriveObject|DrivesCollection|FileExists|FolderExists|GetDrive|GetDriveName|IsReady FileSystemObject

©2000MicrosoftCorporation

JScript

Exists

Dictionary true false

object.Exists(key)

object Dictionary

key Dictionary key

Exists

functionkeyExists(k){varfso,s="";d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");d.Add("b","Belgrade");d.Add("c","Cairo");if(d.Exists(k))s+="Specifiedkeyexists.";elses+="Specifiedkeydoesn'texist.";return(s);}

Add(Dictionary) |Items|Keys|Remove|RemoveAllDictionary

©2000MicrosoftCorporation

JScript

FileExists

True; False

object.FileExists(filespec)

objectFileSystemObject

filespec.,

FileExists

functionReportFileStatus(filespec){varfso,s=filespec;fso=newActiveXObject("Scripting.FileSystemObject");if(fso.FileExists(filespec))s+="exists.";elses+="doesn'texist.";return(s);}

DriveExists|FolderExists|GetFile|GetFileNameFileSystemObject

©2000MicrosoftCorporation

JScript

FolderExists

True False

object.FolderExists(folderspec)

objectFileSystemObject

folderspec

FileExists

functionReportFolderStatus(fldr){varfso,s=fldr;fso=newActiveXObject("Scripting.FileSystemObject");if(fso.FolderExists(fldr))s+="exists.";elses+="doesn'texist.";return(s);}

DriveExists|FileExists|GetFolder|GetParentFolderNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetAbsolutePathName

object.GetAbsolutePathName(pathspec)

objectFileSystemObject

pathspec

(\)

c:\mydocuments\reports GetAbsolutePathName

pathspec"c:" "c:\mydocuments\reports""c:.." "c:\mydocuments""c:\\" "c:\""c:*.*\\may97" "c:\mydocuments\reports\*.*\may97""region1" "c:\mydocuments\reports\region1""c:\\..\\..\\mydocuments" "c:\mydocuments"

GetAbsolutePathName

functionShowAbsolutePath(path){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetAbsolutePathName(path);

return(s);}

GetBaseName|GetDrive|GetDriveName|GetExtensionName|GetFile|GetFileName|GetFlieVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetBaseName

object.GetBaseName(path)

objectFileSystemObject

path

path GetBaseName("")

GetBaseName path

GetBaseName

functionShowBaseName(filespec){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetBaseName(filespec);return(s);}

GetAbsolutePathName|GetDrive|GetDriveName|GetExtensionName

|GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetDrive

Drive

object.GetDrive(drivespec);

objectFileSystemObject

drivespec drivespec(c)(c:)(c:\)(\\computer2\share1)

drivespec

GetDrive drivespec

DriveSpec=GetDriveName(GetAbsolutePathName(Path))

GetDrive

functionShowFreeSpace(drvPath){varfso,d,s="";fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath.toUpperCase()+"-";s+=d.VolumeName+"<br>";

s+="FreeSpace:"+d.FreeSpace/1024+"Kbytes";return(s);}

GetAbsolutePathName|GetBaseName|GetDriveName|GetExtensionName|GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempName FileSystemObject

©2000MicrosoftCorporation

JScript

GetDriveName

object.GetDriveName(path)

objectFileSystemObject

path

GetDriveName("")

GetDriveName path

GetDriveName

functionGetDriveLetter(path){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(path)return(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetExtensionName

|GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetExtensionName

object.GetExtensionName(path)

objectFileSystemObject

path

(\)

path GetExtensionName("")

GetExtensionName

functionShowExtensionName(filespec){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetExtensionName(filespec);return(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|

GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetFile

File

object.GetFile(filespec)

objectFileSystemObject

filespec filespec

GetFile

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.Path.toUpperCase()+"<br>";s+="Created:"+f.DateCreated+"<br>";s+="LastAccessed:"+f.DateLastAccessed+"<br>";s+="LastModified:"+f.DateLastModifiedreturn(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|GetExtensionName|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetFileName

object.GetFileName(pathspec)

objectFileSystemObject

pathspec

pathspec GetFileName("")

GetFileName

GetFileName

functionShowFileName(filespec){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetFileName(filespec);return(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|

GetExtensionName|GetFile|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

getFileVersion

Object.GetFileVersion(pathspec)

object FileSystemObject

pathspec

pathspec GetFileVersion0("")

GetFileVersion

GetFileVersion

functionShowFileVersion(pathspec){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetFileVersion(pathspec);if(s=="")s=" ";return(s);}

1

©2000MicrosoftCorporation

JScript

GetFolder

Folder

object.GetFolder(folderspec)

objectFileSystemObject

folderspec folderspec

GetFolder

functionShowFolderList(folderspec){varfso,f,fc,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(folderspec);fc=newEnumerator(f.SubFolders);s="";for(;!fc.atEnd();fc.moveNext()){s+=fc.item();s+="<br>";

}return(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|GetExtensionName|GetFile|GetFileName|GetFileVersion|GetParentFolderName|GetSpecialFolder|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetParentFolderName

object.GetParentFolderName(path)

objectFileSystemObject

path

path GetParentFolderName("")

GetParentFolderName path

GetParentFolderName

functionShowParentFolderName(filespec){varfso,s="";fso=newActiveXObject("Scripting.FileSystemObject");s+=fso.GetParentFolderName(filespec);return(s);}

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|

GetExtensionName|GetFile|GetFileName|GetFileVersion|GetFolder|GetSpecialFolder|GetTempName FileSystemObject

©2000MicrosoftCorporation

JScript

GetSpecialFolder

object.GetSpecialFolder(folderspec)

objectFileSystemObject

folderspec

folderspec

WindowsFolder 0 WindowsWindowsSystemFolder 1 SystemTemporaryFolder 2 TempTMP

GetSpecialFolder

varfso,tempfile;fso=newActiveXObject("Scripting.FileSystemObject");

functionCreateTempFile(){vartfolder,tfile,tname,fname,TemporaryFolder=2;tfolder=fso.GetSpecialFolder(TemporaryFolder);tname=fso.GetTempName();

tfile=tfolder.CreateTextFile(tname);return(tfile);}tempfile=CreateTempFile();tempfile.writeline("HelloWorld");tempfile.close();

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|GetExtensionName|GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetTempNameFileSystemObject

©2000MicrosoftCorporation

JScript

GetTempName

object.GetTempName();

object FileSystemObject

GetTempName CreateTextFile

GetTempName

varfso,tempfile;fso=newActiveXObject("Scripting.FileSystemObject");

functionCreateTempFile(){vartfolder,tfile,tname,fname,TemporaryFolder=2;tfolder=fso.GetSpecialFolder(TemporaryFolder);tname=fso.GetTempName();tfile=tfolder.CreateTextFile(tname);return(tfile);}tempfile=CreateTempFile();tempfile.writeline("HelloWorld");tempfile.close();

GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|

GetExtensionName|GetFile|GetFileName|GetFileVersion|GetFolder|GetParentFolderName|GetSpecialFolderFileSystemObject

©2000MicrosoftCorporation

JScript

Items

Dictionary

object.Items()

object Dictionary

Items

functionItemsDemo(){vara,d,i,s;//d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");//d.Add("b","Belgrade");d.Add("c","Cairo");a=(newVBArray(d.Items())).toArray();//s="";for(iina)// dictionary{s+=a[i]+"<br>";}return(s);//}

Add(Dictionary) |Exists|Keys|Remove|RemoveAllDictionary

©2000MicrosoftCorporation

JScript

Keys

Dictionary

object.Keys()

object Dictionary

Keys

functionKeysDemo(){vara,d,i,s;//d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");//d.Add("b","Belgrade");d.Add("c","Cairo");a=(newVBArray(d.Keys())).toArray();//s="";for(iina)// dictionary{s+=a[i]+"-"+d(a[i])+"<br>";}return(s);//}

Add(Dictionary) |Exists|Items|Remove|RemoveAllDictionary

©2000MicrosoftCorporation

JScript

Move

object.Move(destination);

object File Folder

destination

MoveFileFolderFileSystemObject.MoveFileFileSystemObject.MoveFolder

Copy|Delete|MoveFile|MoveFolder|OpenAsTextStreamFile|Folder

©2000MicrosoftCorporation

JScript

MoveFile

object.MoveFile(source,destination);

objectFileSystemObject

source source

destination destination

source destination(\) destinationdestination

destination

destination

destination

source MoveFile

MoveFile

functionMoveFile2Desktop(filespec){varfso;

fso=newActiveXObject("Scripting.FileSystemObject");fso.MoveFile(filespec,"c:\\windows\\desktop\\");}

CopyFile|DeleteFile|GetFile|GetFileName|Move|MoveFolder|OpenTextFile FileSystemObject

©2000MicrosoftCorporation

JScript

MoveFolder

object.MoveFolder(source,destination);

objectFileSystemObject

source source

destination destination

source destination(\) destinationdestination

destination

destination

destination

source MoveFolder

MoveFolder

functionMoveFldr2Desktop(fldrspec){varfso;

fso=newActiveXObject("Scripting.FileSystemObject");fso.MoveFolder(fldrspec,"c:\\windows\\desktop\\");}

CopyFile|DeleteFile|GetFile|GetFileName|Move|MoveFile|OpenTextFile FileSystemObject

©2000MicrosoftCorporation

JScript

OpenAsTextStream

TextStream

object.OpenAsTextStream([iomode,[format]])

object File

iomode/ ForReading ForWriting ForAppending

format ASCII

iomode

ForReading 1 ForWriting 2 ForAppending 8

format

TristateUseDefault -2TristateTrue -1 UnicodeTristateFalse 0 ASCII

OpenAsTextStreamFileSystemObjectOpenTextFileOpenAsTextStream

OpenAsTextStream

functionTextStreamTest(){varfso,f,ts,s;varForReading=1,ForWriting=2,ForAppending=8;varTristateUseDefault=-2,TristateTrue=-1,TristateFalse=0;fso=newActiveXObject("Scripting.FileSystemObject");fso.CreateTextFile("test1.txt");//f=fso.GetFile("test1.txt");ts=f.OpenAsTextStream(ForWriting,TristateUseDefaultts.Write("HelloWorld");ts.Close();ts=f.OpenAsTextStream(ForReading,TristateUseDefaults=ts.ReadLine();ts.Close();return(s);}

Copy|CreateTextFile|Delete|Move|OpenTextFile File

©2000MicrosoftCorporation

JScript

OpenTextFile

TextStream

object.OpenTextFile(filename[,iomode[,create[,format]]])

object object FileSystemObject

filename

iomodeForReadingForWritingForAppending

createBoolean filename True False

format ASCII

iomode

ForReading 1 ForWriting 2ForAppending 8

format

TristateTrue Unicode

TristateFalse ASCIITristateUseDefault

OpenTextFile

varfs,a,ForAppending;ForAppending=8;fs=newActiveXObject("Scripting.FileSystemObject");a=fs.OpenTextFile("c:\\testfile.txt",ForAppending,false...a.Close();

CreateTextFile|OpenAsTextStream FileSystemObject

©2000MicrosoftCorporation

JScript

Read

TextStream

object.Read(characters)

object TextStream

characters

ReadHeader

functionGetHeader(){varfso,f;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.Write("Header");f.Write("1234567890987654321");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);return(f.Read(6));}

ReadAll|ReadLine|Skip|SkipLine TextStream

©2000MicrosoftCorporation

JScript

ReadAll

TextStream

object.ReadAll();

object TextStream

ReadAll

ReadAll

functionGetEverything(){varfso,f;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.Write("Header");f.Write("1234567890987654321");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);return(f.ReadAll());}

Read|ReadLine|Skip|SkipLine

TextStream

©2000MicrosoftCorporation

JScript

ReadLine

TextStream

object.ReadLine()

object TextStream

Line

functionGetLine(){varfso,f,r;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.WriteLine("Helloworld!");f.WriteLine("JScriptisfun");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);r=f.ReadLine();return(r);}

Read|ReadAll|Skip|SkipLine TextStream

©2000MicrosoftCorporation

JScript

Remove

Dictionary

object.Remove(key)

object Dictionary

key key Dictionary

Remove

vara,d,i,s;//d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");//d.Add("b","Belgrade");d.Add("c","Cairo");...d.Remove("b");//

Add(Dictionary) |Exists|Items|Keys|RemoveAllDictionary

©2000MicrosoftCorporation

JScript

RemoveAll

RemoveAll Dictionary

object.RemoveAll()

object Dictionary

RemoveAll

vara,d,i;//d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");//d.Add("b","Belgrade");d.Add("c","Cairo");...d.RemoveAll();// dictionary

Add(Dictionary) |Exists|Items|Keys|Remove Dictionary

©2000MicrosoftCorporation

JScript

Skip

TextStream

object.Skip(characters)

object TextStream

characters

Skip

functionSkipDemo(){varfso,f,r;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject")f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.WriteLine("Helloworld!");f.WriteLine("JScriptisfun");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);f.Skip(6);

r=f.ReadLine();return(r);}

Close|Read|ReadAll|ReadLine|SkipLine|Write|WriteLine|WriteBlankLines TextStream

©2000MicrosoftCorporation

JScript

SkipLine

TextStream

object.SkipLine()

object TextStream

SkipLine

functionSkipLineDemo(){varfso,f,rvarForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject")f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true)f.WriteLine("Helloworld!");f.WriteLine("JScriptisfun");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);f.SkipLine();r=f.ReadLine();return(r);}

Read|ReadAll|ReadLine|Skip TextStream

©2000MicrosoftCorporation

JScript

Write

TextStream

object.Write(string)

object TextStream

string

WriteLine

Write

functionWriteDemo(){varfso,f,rvarForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject")f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true)f.Write("Helloworld!");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);r=f.ReadLine();return(r);}

WriteBlankLines|WriteLine TextStream

©2000MicrosoftCorporation

JScript

WriteBlankLines

TextStream

object.WriteBlankLines(lines)

object TextStream

lines

WriteBlankLines

functionWriteBlanksDemo(){varfso,f,r;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.Write("Helloworld!");f.WriteBlankLines(2);f.Write("JScriptisfun!");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);r=f.ReadAll();return(r);

}

Write|WriteLine TextStream

©2000MicrosoftCorporation

JScript

WriteLine

TextStream

object.WriteLine([string])

object TextStream

string

WriteLine

varfso,f;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.CreateTextFile("c:\\testfile.txt",true);f.WriteLine("Thisisatest.");f.Close();

Write|WriteBlankLines TextStream

©2000MicrosoftCorporation

JScript

Script

DictionaryDriveDrivesFile

File FilesFileSystemObjectFolder

FolderFolder Folders

TextStream

©2000MicrosoftCorporation

JScript

Dictionary

y=newActiveXObject("Scripting.Dictionary")

DictionaryPERL

Dictionary:

vary=newActiveXObject("Scripting.Dictionary");y.add("a","test");if(y.Exists("a"))document.write("true");...

Add(Dictionary) |Exists|Items|Keys|Remove|RemoveAll

Count|Item|Key

FileSystemObject|TextStream

©2000MicrosoftCorporation

JScript

Drive

Drive

functionShowFreeSpace(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath+"-";s+=d.VolumeName+"<br>";s+="FreeSpace:"+d.FreeSpace/1024+"Kbytes";return(s);}

Drive

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize

|VolumeName

Drives|File|Files|Folder|Folders|GetDrive

©2000MicrosoftCorporation

JScript

Drives

Drives

Drives Drives Enumerator

functionShowDriveList(){varfso,s,n,e,x;fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);s="";for(;!e.atEnd();e.moveNext()){x=e.item();s=s+x.DriveLetter;s+="-";if(x.DriveType==3)n=x.ShareName;elseif(x.IsReady)n=x.VolumeName;elsen="[Drivenotready]";s+=n+"<br>";}return(s);

}

Count|Item

Drive|Drives|File|Files|Folder|Folders

©2000MicrosoftCorporation

JScript

File

File

functionShowFileInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.DateCreated;return(s);}

Copy|Delete|Move|OpenAsTextStream

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Name|ParentFolder|Path|ShortName|ShortPath|Size

|Type

Drive|Drives|Files|Folder|Folders

©2000MicrosoftCorporation

JScript

Files

File

Files Enumerator for

functionShowFolderFileList(folderspec){varfso,f,f1,fc,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(folderspec);fc=newEnumerator(f.files);s="";for(;!fc.atEnd();fc.moveNext()){s+=fc.item();s+="<br>";}return(s);}

Files

Count|Item

Drive|Drives|File|Folder|Folders

©2000MicrosoftCorporation

JScript

FileSystemObject

y=newActiveXObject("Scripting.FileSystemObject")

FileSystemObjext TextStream

varfso=newActiveXObject("Scripting.FileSystemObjectvara=fso.CreateTextFile("c:\\testfile.txt",true);a.WriteLine("Thisisatest.");a.Close();

ActiveXObject FileSystemObject(fso) CreateTextFileTextStream(a) WriteLine Close

BuildPath|CopyFile|CopyFolder|CreateFolder|CreateTextFile|DeleteFile|DeleteFolder|DriveExists|FileExists|FolderExists|GetAbsolutePathName|GetBaseName|GetDrive|GetDriveName|GetExtensionName|GetFile|GetFileName|GetFolder|GetParentFolderName|GetSpecialFolder|GetTempName|MoveFile|MoveFolder|OpenTextFile

Drives

Dictionary|Drive|Drives|File|Files|Folder|Folders|

TextStream

©2000MicrosoftCorporation

JScript

Folder

Folder

functionShowFolderInfo(folderspec){varfso,folder,s;fso=newActiveXObject("Scripting.FileSystemObject");folder=fso.GetFolder(folderspec);s=folder.DateCreated;return(s);}

Copy|Delete|Move|OpenAsTextStream

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|Size|SubFolders|Type

Drive|Drives|File|Files|Folders

©2000MicrosoftCorporation

JScript

Folders

Folder Folder

Folders Enumerator for

functionShowFolderList(folderspec){varfso,f,fc,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(folderspec);fc=newEnumerator(f.SubFolders);s="";for(;!fc.atEnd();fc.moveNext()){s+=fc.item();s+="<br>";}return(s);}

Add(Folders)

Count|Item

Drive|Drives|File|Files|Folder|SubFolders

©2000MicrosoftCorporation

JScript

TextStream

TextStream.{property|method()}

property method TextStream TextStreamFileSystemObject TextStream

aFileSystemObjectCreateTextFileTextStream

varfso=newActiveXObject("Scripting.FileSystemObject");vara=fso.CreateTextFile("c:\\testfile.txt",true);a.WriteLine(" ");a.Close();

WriteLineCloseTextStream

Close|Read|ReadAll|ReadLine|Skip|SkipLine|Write|WriteBlankLines|WriteLine

AtEndOfLine|AtEndOfStream|Column|Line

Dictionary|FileSystemObject

©2000MicrosoftCorporation

JScript

Script

TextStream TrueFalse AtEndOfLine

TextStream True False AtEndOfStreamAttributesAvailableSpace

TextStream Column Dictionary CompareMode Dictionary Count

DateCreatedDateLastAccessedDateLastModifiedDriveDriveLetter

Drives Drive DrivesDriveType

Files File FilesFileSystemFreeSpace

True False IsReady True False IsRootFolder Dictionary Item Dictionary Key TextStream Line

Namefolder ParentFolder

Path Folder RootFolder

SerialNumberShareName

8.3 ShortName8.3 ShortPath

Size Folders SubFolders

TotalSizeTypeVolumeName

©2000MicrosoftCorporation

JScript

AtEndOfLine

TextStream true false

object.AtEndOfLine

object TextStream

AtEndOfLineTextStream

AtEndOfLine

functionGetALine(filespec){varfso,a,s,ForReading;ForReading=1,s="";fso=newActiveXObject("Scripting.FileSystemObject");a=fso.OpenTextFile(filespec,ForReading,false);while(!a.AtEndOfLine){s+=a.Read(1);}a.Close();return(s);}

AtEndOfStream TextStream

©2000MicrosoftCorporation

JScript

AtEndOfStream

TextStream true false

object.AtEndOfStream

object TextStream

AtEndOfStreamTextStream

AtEndOfStream

functionGetALine(filespec){varfso,f,s,ForReading;ForReading=1,s="";fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile(filespec,ForReading,false);while(!f.AtEndOfStream)s+=f.ReadLine();f.Close();return(s);}

AtEndOfLine TextStream

©2000MicrosoftCorporation

JScript

Attributes

/

object.Attributes[=newattributes]

object File Folder

newattributes newattributes object

newattributes

Normal 0 ReadOnly 1 /Hidden 2 /System 4 /Volume 8 Directory 16 Archive 32 /Alias 64 Compressed 128

Attributes

functionToggleArchiveBit(filespec){

varfso,f,r,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec)if(f.attributes&&32){f.attributes=f.attributes-32;s="Archivebitiscleared.";}else{f.attributes=f.attributes+32;s="Archivebitisset.";}return(s);}

DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath

|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

AvailableSpace

object.AvailableSpace

object Drive

AvailableSpace FreeSpacequotas

AvailableSpace

functionShowAvailableSpace(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath.toUpperCase()+"-";s+=d.VolumeName+"<br>";s+="AvailableSpace:"+d.AvailableSpace/1024+"Kbytes";return(s);}

DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

Column

TextStream

object.Column

object TextStream

Column1

Column

functionGetColumn(){varfso,f,m;varForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.OpenTextFile("c:\\testfile.txt",ForWriting,true);f.Write("HelloWorld!");f.Close();f=fso.OpenTextFile("c:\\testfile.txt",ForReading);m=f.ReadLine();return(f.Column);}

Line TextStream

©2000MicrosoftCorporation

JScript

CompareMode

Dictionary

object.CompareMode[=compare]

object Dictionary

comparecompare0()1(),2()2ID(LCID)

Dictionary

CompareMode

functionTestCompareMode(key){//vara,d;varBinaryCompare=0,TextCompare=1;d=newActiveXObject("Scripting.Dictionary");//d.CompareMode=TextCompare;//d.Add("a","Athens");d.Add("b","Belgrade");

d.Add("c","Cairo");return(d.Item(key));}

Key Dictionary

©2000MicrosoftCorporation

JScript

Count

Dictionary

object.Count

object“”

Count:

functionCountDemo(){vara,d,i,s;//d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");//d.Add("b","Belgrade");d.Add("c","Cairo");a=(newVBArray(d.Keys()));//s="";for(i=0;i<d.Count;i++)// dictionary{s+=a.getItem(i)+"-"+d(a.getItem(i))+"<br>";}return(s);//}

CompareMode|Item|Key Dictionary|Drives|Files|Folders

©2000MicrosoftCorporation

JScript

DateCreated

object.DateCreated

object File Folder

DateCreated

functionShowFileInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s="Created:"+f.DateCreated;return(s);}

Attributes|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath

|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

DateLastAccessed

object.DateLastAccessed

object File Folder

DateLastAccessed

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=filespec.toUpperCase()+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModified;return(s);}

Attributes|DateCreated|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath

|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

DateLastModified

object.DateLastModified

object File Folder

DateLastModified

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=filespec.toUpperCase()+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModified;return(s);}

Attributes|DateCreated|DateLastAccessed|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath

|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

Drive

object.Drive

object File Folder

Drive

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.Name+"onDrive"+f.Drive+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModified;return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

DriveLetter

object.DriveLetter

object Drive

DriveLetter0("")

DriveLetter

functionShowDriveLetter(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+d.DriveLetter.toUpperCase()+":-";s+=d.VolumeName+"<br>";s+="AvailableSpace:"+d.AvailableSpace/1024+"Kbytes";return(s);}

AvailableSpace|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

Drives

Drives Drive

object.Drives

objectFileSystemObject

Drives

Enumerator for Drives

functionShowDriveList(){varfso,s,n,e,x;fso=newActiveXObject("Scripting.FileSystemObject");e=newEnumerator(fso.Drives);s="";for(;!e.atEnd();e.moveNext()){x=e.item();s=s+x.DriveLetter;s+="-";if(x.DriveType==3)n=x.ShareName;elseif(x.IsReady)n=x.VolumeName;elsen="[ ]";

s+=n+"<br>";}return(s);}

Drives|Files|SubFolders FileSystemObject

©2000MicrosoftCorporation

JScript

DriveType

object.DriveType

object Drive

DriveType

functionShowDriveType(drvpath){varfso,d,s,t;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(drvpath);switch(d.DriveType){case0:t="Unknown";break;case1:t="Removable";break;case2:t="Fixed";break;case3:t="Network";break;case4:t="CD-ROM";break;case5:t="RAMDisk";break;}s="Drive"+d.DriveLetter+":-"+t;return(s);}

AvailableSpace|DriveLetter|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

Files

Files File

object.Files

object Folder

Files

functionShowFolderFileList(folderspec){varfso,f,fc,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(folderspec);fc=newEnumerator(f.files);s="";for(;!fc.atEnd();fc.moveNext()){s+=fc.item();s+="<br>";}return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|Size|SubFolders|Type

Folder

©2000MicrosoftCorporation

JScript

FileSystem

object.FileSystem

object Drive

FATNTFSCDFS

FileSystem

functionShowFileSystemType(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(drvPath);s=d.FileSystem;return(s);}

AvailableSpace|DriveLetter|DriveType|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

FreeSpace

object.FreeSpace

object Drive

FreeSpace AvailableSpacequotas

FreeSpace

functionShowFreeSpace(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath.toUpperCase()+"-";s+=d.VolumeName+"<br>";s+="FreeSpace:"+d.FreeSpace/1024+"Kbytes";return(s);}

AvailableSpace|DriveLetter|DriveType|FileSystem|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

IsReady

True False

object.IsReady

object Drive

CD-ROM IsReady True

IsReady

functionShowDriveInfo(drvpath){varfso,d,s,t;fso=newActiveXObject("Scripting.FileSystemObject")d=fso.GetDrive(drvpath)switch(d.DriveType){case0:t="Unknown";break;case1:t="Removable";break;case2:t="Fixed";break;case3:t="Network";break;case4:t="CD-ROM";break;case5:t="RAMDisk";break;}s="Drive"+d.DriveLetter+":-"+t;if(d.IsReady)s+="<br>"+" ";

elses+="<br>"+" ";return(s);}

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|Path|RootFolder|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

IsRootFolder

True False

object.IsRootFolder

object Folder

IsRootFolder

functionDisplayLevelDepth(pathspec){varfso,f,n,s="";fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(pathspec);n=0;if(f.IsRootFolder)s="Thespecifiedfolderistherootfolder."else{do{f=f.ParentFolder;n++;}while(!f.IsRootFolder)s="Thespecifiedfolderisnested"+n+"levelsdeep."}

return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|Name|ParentFolder|Path|ShortName|ShortPath

|Size|SubFolders|Type Folder

©2000MicrosoftCorporation

JScript

Item

Dictionary key item key item/

object.Item(key)[=newitem]

Item

object Dictionarykey item key

newitem Dictionary newitem key

key item newitem key key key

Item

functionDicTest(keyword){vara,d;d=newActiveXObject("Scripting.Dictionary");d.Add("a","Athens");d.Add("b","Belgrade");d.Add("c","Cairo");a=d.Item(keyword);return(a);}

CompareMode|Count|Key

Dictionary|Drives|Files|Folders

©2000MicrosoftCorporation

JScript

Key

Dictionary key

object.Key(key)=newkey

Key

object Dictionarykey keynewkey key

key key key item

Key

vard;d=newActiveXObject("Scripting.Dictionary");

functionAddStuff(){vara;d.Add("a","Athens");d.Add("b","Belgrade");d.Add("c","Cairo");}

functionChangeKey(oldkey,newkey){vars;

d.Key("c")="Ca";s="Key"+oldkey+"changedto"+newkey;return(s);}

CompareMode|Count|Item Dictionary

©2000MicrosoftCorporation

JScript

Line

TextStream

object.Line

object TextStream

Line1

Line

functionGetLine(){varfso,f,rvarForReading=1,ForWriting=2;fso=newActiveXObject("Scripting.FileSystemObject")f=fso.OpenTextFile("c:\\textfile.txt",ForWriting,true)f.WriteLine("Helloworld!");f.WriteLine("JScriptisfun");f.Close();f=fso.OpenTextFile("c:\\textfile.txt",ForReading);r=f.ReadAll();return(f.Line);}

Column TextStream

©2000MicrosoftCorporation

JScript

Name

/

object.Name[=newname]

Name

object File Folder

newname newname object

Name

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.Name+"onDrive"+f.Drive+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModified;return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|ParentFolder|Path|ShortName|

ShortPath|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

ParentFolder

object.ParentFolder

object File Folder

ParentFolder

functionShowFileAccessInfo(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.Name+"in"+f.ParentFolder+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModified;return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|Path|ShortName|ShortPath|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

Path

object.Path

object FileFolder Drive

CC:C:\

File Path

functionShowFileAccessInfo(filespec){varfso,d,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s=f.Path.toUpperCase()+"<br>";s+=" "+f.DateCreated+"<br>";s+=" "+f.DateLastAccessed+"<br>";s+=" "+f.DateLastModifiedreturn(s);}

Attributes|AvailableSpace|DateCreated|DateLastAccessed|DateLastModified|Drive|DriveLetter|DriveType|Files|FileSystem|FreeSpace|IsReady|IsRootFolder|Name|ParentFolder|RootFolder|SerialNumber|ShareName|ShortName|ShortPath|Size|SubFolders|TotalSize|Type|VolumeName

Drive|File|Folder

©2000MicrosoftCorporation

JScript

RootFolder

Folder

object.RootFolder

object Drive

Folder

RootFolder

functionGetRootFolder(drv){varfso,d;fso=newActiveXObject("Scripting.FileSystemObject");if(fso.DriveExists(drv)){d=fso.GetDrive(drv);return(d.RootFolder);}elsereturn(false);}

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|SerialNumber|ShareName|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

SerialNumber

object.SerialNumber

object Drive

SerialNumber

SerialNumber

functionShowDriveInfo(drvpath){varfso,d,s,t;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)));switch(d.DriveType){case0:t="Unknown";break;case1:t="Removable";break;case2:t="Fixed";break;case3:t="Network";break;case4:t="CD-ROM";break;case5:t="RAMDisk";break;}s="Drive"+d.DriveLetter+":-"+t;s+="<br>"+"SN:"+d.SerialNumber;return(s);}

1

©2000MicrosoftCorporation

JScript

ShareName

object.ShareName

object Drive

object ShareName("")

ShareName

functionShowDriveInfo(drvpath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)));s="Drive"+d.DriveLetter+":-"+d.ShareName;return(s);}

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|TotalSize|VolumeName Drive

©2000MicrosoftCorporation

JScript

ShortName

8.3

object.ShortName

object File Folder

File ShortName

functionShowShortName(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s="Theshortnamefor"+""+f.Name;s+=""+"<br>";s+="is:"+""+f.ShortName+"";return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortPath|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

ShortPath

8.3

object.ShortPath

object File Folder

File ShortName

functionShowShortPath(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFile(filespec);s="Theshortpathfor"+""+f.Name;s+=""+"<br>";s+="is:"+""+f.ShortPath+"";return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|Size|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

Size

object.Size

object File Folder

Folder Size

functionShowFolderSize(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(filespec);s=f.Name+"uses"+f.size+"bytes.";return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|SubFolders|Type File|Folder

©2000MicrosoftCorporation

JScript

SubFolders

Folders

object.SubFolders

object Folder

SubFolders

functionShowFolderList(folderspec){varfso,f,fc,s;fso=newActiveXObject("Scripting.FileSystemObject");f=fso.GetFolder(folderspec);fc=newEnumerator(f.SubFolders);s="";for(;!fc.atEnd();fc.moveNext()){s+=fc.item();s+="<br>";}return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|Size|Type

Folder

©2000MicrosoftCorporation

JScript

TotalSize

object.TotalSize

object Drive

TotalSize

functionSpaceReport(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath+"-";s+=d.VolumeName+"<br>";s+="TotalSpace:"+d.TotalSize/1024+"Kbytes<br>";s+="FreeSpace:"+d.FreeSpace/1024+"Kbytes";return(s);}

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|VolumeName Drive

©2000MicrosoftCorporation

JScript

Type

.TXT“”

object.Type

object File Folder

Type

functionShowFileType(filespec){varfso,f,s;fso=newActiveXObject("Scripting.FileSystemObject");if(fso.FolderExists(filespec))f=fso.GetFolder(filespec);elseif(fso.FileExists(filespec))f=fso.GetFile(filespec);elses="FileorFolderdoesnotexist.";s=f.Name+"isa"+f.Type;return(s);}

Attributes|DateCreated|DateLastAccessed|DateLastModified|Drive|Files|IsRootFolder|Name|ParentFolder|Path|ShortName|ShortPath|Size|SubFolders File|Folder

©2000MicrosoftCorporation

JScript

VolumeName

/

object.VolumeName[=newname]

object Drive

newname, newname object

VolumeName

functionSpaceReport(drvPath){varfso,d,s;fso=newActiveXObject("Scripting.FileSystemObject");d=fso.GetDrive(fso.GetDriveName(drvPath));s="Drive"+drvPath+"-";s+=d.VolumeName+"<br>";s+="TotalSpace:"+d.TotalSize/1024+"Kbytes<br>";s+="FreeSpace:"+d.FreeSpace/1024+"Kbytes";return(s);}

AvailableSpace|DriveLetter|DriveType|FileSystem|FreeSpace|IsReady|Path|RootFolder|SerialNumber|ShareName|TotalSize

Drive

©2000MicrosoftCorporation

JScript

“”

©2000MicrosoftCorporation

JScript

?*?*'data?.dat'

data1.dat

data2.dat

datax.dat

dataN.dat

*?'data*.dat'

data.dat

data1.dat

data2.dat

data12.dat

datax.dat

dataXYZ.dat

?*

©2000MicrosoftCorporation

JScript

“”WarrenMcCullochWalterPitts

1956,StephenKleeneMcCullochPitts“”“”“”

KenThompsonKenThompsonUnixUnix qed

©2000MicrosoftCorporation

JScript

webHTMLHTML

VBScriptVisualBasicCJscriptJScriptVBScript

©2000MicrosoftCorporation

JScript

az

JScript VBScript/^\[\t]*$/ "^\[\t]*$"/\d{2}-\d{5}/ "\d{2}-\d{5}" ID25/<(.*)>.*<\/\1>/ "<(.*)>.*<\/\1>" HTML

\ 'n'"n"'\n''\\'"\""\(""("^ RegExp Multiline^'\n''\r'$ RegExp Multiline$'\n''\r'* zo*"z""zoo"*{0,}+ 'zo+'"zo""zoo""z"+{1,}? "do(es)?""do""does""do"?{0,1}{n} n n'o{2}'"Bob"'o'"food"o

{n,} n n'o{2,}'"Bob"'o'"foooood"o'o{1,}''o+''o{0,}''o*'

{n,m} m n n<=m n m"o{1,3}""fooooood"o'o{0,1}''o?'

? (*,+,?,{ n},{n,},{n,m})"oooo"'o+?'"o"'o+''o'

. "\n"'\n''[.\n]'

(pattern) patternMatchesVBScript SubMatchesJScript $0…$9'\(''\)'

(?:pattern) pattern""(|)'industr(?:y|ies)'industry|industries'

(?=pattern) pattern'Windows(?=95|98|NT|2000)'"Windows2000""Windows""Windows3.1""Windows"

(?!pattern)Negativelookaheadmatchesthesearchstringatanypointwhereastringnotmatchingpattern'Windows(?!95|98|NT|2000)'"Windows3.1""Windows""Windows2000""Windows"

x|y x y'z|food'"z""food"'(z|f)ood'"zood""food"[xyz] '[abc]'"plain"'a'[^xyz] '[^abc]'"plain"'p'[a-z] '[a-z]''a''z'[^a-z] '[^a-z]''a''z'\b 'er\b'"never"'er'"verb"'er'

\B 'er\B'"verb"'er'"never"'er'\cx x\cMControl-M xA-Za-zc'c'\d [0-9]\D [^0-9]\f \x0c\cL\n \x0a\cJ\r \x0d\cM\s [\f\n\r\t\v]\S [^\f\n\r\t\v]\t \x09\cI\v \x0b\cK\w '[A-Za-z0-9_]'\W '[^A-Za-z0-9_]'\xn n n'\x41'"A"'\x041''\x04'&"1"ASCII.\num num num'(.)\1'\n \ n n n n(0-7) n

\nm \ nmisprecededbyatleastnm nm\ nm n n m n m(0-7)\ nm nm

\nml n(0-3) m l(0-7) nml\un n nUnicode\u00A9(?)

©2000MicrosoftCorporation

JScript

JScript(/)

/expression/

VBScript("")

"expression"

( expression)RegExpPattern

©2000MicrosoftCorporation

JScript

\(),(?:),(?=),[]*,+,?,{n},{n,},{n,m}^,$,\anymetacharacter| “”

©2000MicrosoftCorporation

JScript

'A''A'

/a//7//M/

VBScript

"a""7""M"

JScript'a''7''M'

/a7M/

VBScript

"a7M"

©2000MicrosoftCorporation

JScript

(\)

$ RegExp Multiline$'\n''\r'$\$

() \(\)* *\*+ +\+. \n.\[ [\[? ?\?

\ 'n''n''\n''\\'"\"'\('"("

^ ^\^{ {\{| |\|

©2000MicrosoftCorporation

JScript

\cx x\cMControl-M xA-Za-zc'c'

\f \x0c\cL\n \x0a\cJ\r \x0d\cM\s [\f\n\r\t\v]\S [^\f\n\r\t\v]\t \x09\cI\v \x0b\cK

©2000MicrosoftCorporation

JScript

(.)(\n)JScript'aac''abc''acc''adc''a1c''a2c'a-c'a#c'

/a.c/

VBScript

"a.c"

(.)(\)JScript'filename.ext'

/filename\.ext/

VBScript

"filename\.ext"

Chapter1,Chapter2

([])

']'']''['

'\''\''\\'

JScript'Chapter1''Chapter2''Chapter3''Chapter4''Chapter5'

/Chapter[12345]/

VBScript

"Chapter[12345]"

'Chapter''Chapter'

JScript

/Chapter[1-5]/

VBScipt

"Chapter[1-5]"

Unicode

[\-]

[-a-z][a-z-]

[!--][!-~]

(^)JScript5

/Chapter[^12345]/

VBScript

"Chapter[^12345]"

1,2,3,4,or5'Chapter7''Chapter9'

(-)JScript

/Chapter[^1-5]/

VBScript

"Chapter[^1-5]"

JScript

/[A-Za-z0-9]/

VBScript

"[A-Za-z0-9]"

©2000MicrosoftCorporation

JScript

* zo*"z""zoo"*{0,}+ 'zo+'"zo""zoo""z"+{1,}? "do(es)?""do""does""do"?{0,1}{n} n n'o{2}'"Bob"'o'"food"o

{n,} n n'o{2,}'"Bob"'o'"foooood"o'o{1,}''o+''o{0,}''o*'

{n,m} m n n<=m n m"o{1,3}""fooooood"o'o{0,1}''o?'

JScript

/Chapter[1-9][0-9]*/

VBScript

"Chapter[1-9][0-9]*"

09

'+''?''Chapter'

99JScript

/Chapter[0-9]{1,2}/

VBScript

"Chapter[0-9]{1,2}"

99Chapter0JScript

/Chapter[1-9][0-9]?/

/Chapter[1-9][0-9]{0,1}/

VBScript

"Chapter[1-9][0-9]?"

"Chapter[1-9][0-9]{0,1}"

'*'' +'' ?'

HTMLH1

<H1>Chapter1–IntroductiontoRegularExpressions</H1>

(<)H1

/<.*>/

VBScript

"<.*>"

H1<H1>

/<.*?>/

"<.*?>"

'*''+''?''?'

©2000MicrosoftCorporation

JScript

'Chapter'

^ RegExp Multiline^'\n''\r'

$ RegExp Multiline$'\n''\r'

\b\B

'^*'

'^''^'

'$'

JScript

/^Chapter[1-9][0-9]{0,1}/

VBScript

"^Chapter[1-9][0-9]{0,1}"

/^Chapter[1-9][0-9]{0,1}$/

VBScript

"^Chapter[1-9][0-9]{0,1}$"

JScript'Chapter'

/\bCha/

VBScript

"\bCha"

'\b''Chapter''ter'

/ter\b/

"ter\b"

'apt''Chapter''aptitude''apt'

/\Bapt/

"\Bapt"

'Chapter''apt''aptitude'

©2000MicrosoftCorporation

JScript

'|''|'JScriptVBScript'Chapter''Section'

/^Chapter|Section[1-9][0-9]{0,1}$/"^Chapter|Section[1-9][0-9]{0,1}$"

'Chapter''Section''Chapter22''Chapter''Section22''Section22'

'Chapter''Section''Chapter1''Section3'

'Chapter''Section'JScript

/^(Chapter|Section)[1-9][0-9]{0,1}$/

VBScript

"^(Chapter|Section)[1-9][0-9]{0,1}$"

'Chapter|Section' submatchVBScript SubmatchesJScript RegExp $1-$9

'Chapter''Section'

'?:'JScript

/^(?:Chapter|Section)[1-9][0-9]{0,1}$/

VBScript

"^(?:Chapter|Section)[1-9][0-9]{0,1}$"

'?:' ?='?!'

Windows3.1Windows95Windows98WindowsNT

Windows95Windows98WindowsNTWindows2000JScriptWindows95Windows98WindowsNT

/Windows(?=95|98|NT)/

VBScript

"Windows(?=95|98|NT)"

'Windows98''Windows''98'

©2000MicrosoftCorporation

JScript

'?:','?=',or'?!'

199'\ n' n

Isisthecostofofgasolinegoingupup?

JScript

/\b([a-z]+)\1\b/gi

VBScript

"\b([a-z]+)\1\b"

'[a-z]+''\1'"isissued""thisis"

JScript('g')('i')VBScript RegExp

JScript

varss="Isisthecostofofgasolinegoingupup?.\n";varre=/\b([a-z]+)\1\b/gim;// .varrv=ss.replace(re,"$1");// .

VBScript

Dimss,re,rvss="Isisthecostofofgasolinegoingupup?."&vbNewLineSetre=NewRegExp

re.Pattern="\b([a-z]+)\1\b"re.Global=Truere.IgnoreCase=Truere.MultiLine=Truerv=re.Replace(ss,"$1")VBScript RegExp

replace $1 $2,$3

(URI)URI(ftp,http,etc)/

http://msdn.microsoft.com:80/scripting/default.htm

JScript

/(\w+):\/\/([^/:]+)(:\d*)?([^#]*)/

VBScript

"(\w+):\/\/([^/:]+)(:\d*)?([^#]*)"

web'^''/'':'web\'#'

URI

RegExp.$1"http"

RegExp.$2"msdn.microsoft.com"

RegExp.$3":80"

RegExp.$4"/scripting/default.htm"

©2000MicrosoftCorporation

JScript

JScript

©2000MicrosoftCorporation

JScript

Microsoft®JScript®

URLInternetWebMicrosoftCorporation

MicrosoftMicrosoft

©1991-2000MicrosoftCorporation

MicrosoftMSMS-DOSActiveXJScriptMicrosoftPressMSDNVisualBasicWindowsWindowsNTWin32Win32sMicrosoftCorporation

©2000MicrosoftCorporation

JScript

JScript

ASCII

(ASCII)7ASCIIANSI128(0–127)

Automation

Automation

Boolean

true falseBooleanBoolean

true

false

null undefinedfalse

false

ASCII

JScript///**/

(<)(<=)(>)(>=)(!=)(==)

({})

JScript

new

this

JScriptJScriptArrayBooleanDateFunctionGlobalMathNumberObjectRegExpRegularExpressionString

/

“”“”

null

null null

null

null

JScriptJScriptBooleanprimitive

String

(UTC)

GMT

JScript

Number Boolean

©2000MicrosoftCorporation

JScript

MicrosoftJScript

1.0 2.0 3.0 4.0 5.0 5.1 5.5MicrosoftInternetExplorer3.0 x MicrosoftInternetInformationServer1.0 x MicrosoftInternetExplorer4.0 x MicrosoftInternetInformationServer4.0 x MicrosoftWindowsScriptingHost1.0 x MicrosoftVisualStudio6.0 x MicrosoftInternetExplorer5.0 x MicrosoftInternetInformationServices5.0 x MicrosoftWindows2000 x MicrosoftInternetExplorer5.5 x

JScript

1.0 2.0 3.0 4.0 5.0 5.50…n x$1...$9 x abs x acos x ActiveXObject x + x anchor x apply xarguments x Array x asin x = x atan x atan2 x atEnd x big x & x << x ~ x | x >> x ^ x blink x

bold x Boolean x break x call xcallee xcaller x catch x @cc_on x ceil x charAt x charCodeAt x, x // x /*..*/ x

x compile x concatArray x concatString x

x x

?: x constructor x continue x cos x

x Date x decodeURI xdecodeURIComponent x-- x delete x description x dimensions x / x do...while x E x encodeURI xencodeURI xEnumerator x == x Error x escape x eval x exec x exp x fixed x

floor x fontcolor x fontsize x for x for...in x fromCharCode x Function x function x getDate x getDay x getFullYear x getHours x getItem x getMilliseconds x getMinutes x getMonth x GetObject x getSeconds x getTime x getTimezoneOffset x getUTCDate x getUTCDay x getUTCFullYear x getUTCHours x getUTCMilliseconds x getUTCMinutes x getUTCMonth x getUTCSeconds x getVarDate x getYear x Global x global x> x >= x hasOwnProperty x=== x @if x if...else x ignoreCase x++ x index x indexOf x != x Infinity x input x

instanceof x isFinite x isNaN x isPrototypeOf xitalics x item x join x Labeled x lastIndex x lastIndexOf x lastMatch xlastParen xlbound x leftContext xlengthArguments xlengthArray x lengthFunction x lengthString x < x <= x link x LN2 x LN10 x localeCompare xlog x LOG2E x LOG10E x && x ! x || x match x Math x max x MAX_VALUE x message xmin x MIN_VALUE x % x moveFirst x moveNext x multiline x* x name xNaNGlobal x NaNNumber x

NEGATIVE_INFINITY x new x !== x Number x number x Object x

x parse x parseFloat x parseInt x PI x pop xPOSITIVE_INFINITY x pow x prototype x propertyIsEnumeramble xpush xrandom x RegExp x

x x

replace x return x reverse x rightContext xround x ScriptEngine x ScriptEngineBuildVersion x

ScriptEngineMajorVersion x

ScriptEngineMinorVersion x

search x @set x setDate x setFullYear x setHours x setMilliseconds x setMinutes x setMonth x setSeconds x setTime x setUTCDate x setUTCFullYear x

setUTCHours x setUTCMilliseconds x setUTCMinutes x setUTCMonth x setUTCSeconds x setYear x shift xsin x sliceArray x sliceString x small x sort x source x splice xsplit x sqrt x SQRT1_2 x SQRT2 x strike x String x sub x substr x substring x - x sup x switch x tan x test x this x throw x toArray x toDateString xtoExponential xtoFixed xtoGMTString x toLocaleDateString xtoLocaleLowercase xtoLocaleString x toLocaleTimeString xtoLocaleUppercase xtoLowerCase x toPrecision xtoString x toTimeString xtoUpperCase x

toUTCString x try x typeof x ubound x - x undefined xunescape x unshift x>>> x UTC x valueOf x var x VBArray x void x while x with x

©2000MicrosoftCorporation

JScript

Array

Array(array[0])

varpiArray=newArray(3.14159);

varpiArray=newArray(1);piArray[0]=3.14159;

40

|JScript

©2000MicrosoftCorporation

JScript

Array length Array length( NaN)JScript

length40 Array length

varmy_array=newArray();my_array.length=99;

|JScript

©2000MicrosoftCorporation

JScript

Arrayarguments

Function.prototype.apply Array Arguments

ArrayArguments

|apply|JScript|JScript

©2000MicrosoftCorporation

JScript

Boolean

Boolean Boolean.prototype.toString Boolean.prototype.valueOf Boolean

varo=newObject;o.f=Boolean.prototype.toString;o.f();

BooleanBoolean .prototype.toString Boolean.prototype.valueOf

Boolean|JScript||

©2000MicrosoftCorporation

JScript

myFunction()=42;// 42

myVar=myFunction(42);

myFunction=newFunction("return42;");

Function|JScript |JScript|JScript

©2000MicrosoftCorporation

JScript

'this'

this thisJScript:

JScript this new

this

thiscircle .radius

thisJScript

This||JScript

©2000MicrosoftCorporation

JScript

Date

Date Date.prototype.toString Date.prototype.valueOf Date

varo=newObject;o.f=Date.prototype.toString;o.f();

Date Date.prototype.toString Date.prototype.valueOf

Date|getDate|

©2000MicrosoftCorporation

JScript

Enumerator

Enumerator Enumerator.prototype.atEndEnumerator.prototype.itemEnumerator.prototype.moveFirstEnumerator.prototype.moveNext Enumerator

varo=newObject;o.f=Enumerator.prototype.atEnd;o.f();

Enumerator Enumerator.prototype.atEndEnumerator.prototype.itemEnumerator.prototype.moveFirst Enumerator.prototype.moveNext Enumerator

if(xinstanceofEnumerator)

Enumerator|Files|Folders|Drives

©2000MicrosoftCorporation

JScript

throw try catch try throw try catch

try catch

catch

catch

Error|throw|try...catch

©2000MicrosoftCorporation

JScript

')'

*+?

-\(-JScript)

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

']'

/[abc]/“a”,“b”,“c”

-\(-JScript)

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

prototype

instanceof, prototype(JScript)(,InternetExplorerwindowCOM)

prototypeJScript

Function|prototype

©2000MicrosoftCorporation

JScript

Function

Function Functionprototype foo

varfoo=newObject();// "foo"varx=foo();// foo

Function Functionprototype

()

Function|prototype|JScript

©2000MicrosoftCorporation

JScript

COM

(=)

©2000MicrosoftCorporation

JScript

a-z0-9\w

vargood=/[a-z]/;// -azvarnotGood=/[z-a]/;// -z a

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

JScript

-JScriptJScriptJScript

JScript|

©2000MicrosoftCorporation

JScript

Number

Number Number.prototype.toString Number.prototype.valueOfNumber

NumberNumber.prototype.toStringorNumber.prototype.valueOf

Number|number

©2000MicrosoftCorporation

JScript

Object

Object Object.prototype.toStringObject.prototype.valueOfObject

Object Object.prototype.toString Object.prototype.valueOf

Object|JScript

©2000MicrosoftCorporation

JScript

Object|JScript|JScript

©2000MicrosoftCorporation

JScript

RegExp RegExp.prototype.toString RegExp.prototype.valueOfRegExp

RegExp RegExp.prototype.toString RegExp.prototype.valueOf

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

String

StringString.prototype.toString String.prototype.valueOf

String String.prototype.toString String.prototype.valueOf

String|toString

©2000MicrosoftCorporation

JScript

JScript

JScript

RegularExpression|RegularExpression|RegularExpression|RegularExpression |compile

©2000MicrosoftCorporation

JScript

Number.prototype.toExponential()toExponential()02020

toExponential()

toExponential

©2000MicrosoftCorporation

JScript

Number.prototype.toPrecision toPrecision12121

toPrecision

toPrecision

©2000MicrosoftCorporation

JScript

URI

URIURIURI encodeURIencodeURIComponentJScriptURI

URI

<Scheme>:<first>/<second>;<third>?<fourth>

“:”,“/”,“;”“?”

URIJScript

decodeURI|decodeURIComponent

©2000MicrosoftCorporation

JScript

URI

URIURIUnicode

Unicode

URI

<Scheme>:<first>/<second>;<third>?<fourth>

“:”,“/”,“;”“?”

encodeURI|encodeURIComponent

©2000MicrosoftCorporation

JScript

JScript

var varx)

JScript||JScript

©2000MicrosoftCorporation

JScript

/^+/

^

^$\b\B*+?{n} n{n,} n

{n,m} nm,m

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

VBArray

VisualBasicsafeArray

newVBArray(safeArray);

VBArrayssafeArrayVBArrayVBArrayVBArrayActiveX

VBArrayVBArray

VBArray|

©2000MicrosoftCorporation

JScript

'break'

break break switch switch

break

breaklabelname;

switch break

breakswitch

Break|||JScript

©2000MicrosoftCorporation

JScript

'continue'

continue continue

do-while

while

for

for/in

continue

do-while

while

for

for/in

Continue|||JScript

©2000MicrosoftCorporation

JScript

JScript@

/*@cc_on@*/

/*@cc_on@*/

||@cc_on|@if|@set

©2000MicrosoftCorporation

JScript

'switch''default'

switch defaultDefaultswitch

switchdefaultswitchdefault

Switch||JScript

©2000MicrosoftCorporation

JScript

'('

for(initialize;test;increment){statement;}

JScript

©2000MicrosoftCorporation

JScript

')'

for(initialize;test;increment){statement;}

JScript

©2000MicrosoftCorporation

JScript

'/'

(/)(/)

RegularExpression|RegularExpression

©2000MicrosoftCorporation

JScript

':'

(?:) |JScript|JScript

©2000MicrosoftCorporation

JScript

';'

for

JScript |JScript

©2000MicrosoftCorporation

JScript

'@'

@set@

@

@set@myvar=1

@set||

©2000MicrosoftCorporation

JScript

'@end'

@endJScript @if/@end

@end

|

©2000MicrosoftCorporation

JScript

']'

|Array

©2000MicrosoftCorporation

JScript

'{'

Function|JScript

©2000MicrosoftCorporation

JScript

'}'

for

Function||JScript

©2000MicrosoftCorporation

JScript

'='

@set@myvar1=1

|

©2000MicrosoftCorporation

JScript

'catch'

try catch try throw try trycatch

catch

finally catch

try...catch|Error

©2000MicrosoftCorporation

JScript

|

©2000MicrosoftCorporation

JScript

UnicodeUnicode\uUnicode0-9A-Fa-fUnicode

z="\u1A5F";

Unicode\u09A-Fa-f

t\u_(\\u)–

JScript|JScript

©2000MicrosoftCorporation

JScript

JScript|

©2000MicrosoftCorporation

JScript

(“”):

varpoint={x:1.2,y:-3.4};

(,)

©2000MicrosoftCorporation

JScript

'while'

do…whilewhile do while

while.

while||JScript

©2000MicrosoftCorporation

JScript

JScript

ASCII(_)

ASCII

JScript

JScript||JScript

©2000MicrosoftCorporation

JScript

|switch|break|continue

©2000MicrosoftCorporation

JScript

Labeled|switch|break|continue

©2000MicrosoftCorporation

JScript

'return'

return

() return

return[expression]; return undefined

return return try finally finally

return undefined

return

return|Function|caller

©2000MicrosoftCorporation

JScript

JScript

Error|JScript

©2000MicrosoftCorporation

JScript

Throw

throw throw throw

if(denominator==0){thrownewDivideByZeroException();}

throw

Error|throw|try...catch

©2000MicrosoftCorporation

JScript

"/*""*/"

/**/

“*/”.

©2000MicrosoftCorporation

JScript

String|toString

©2000MicrosoftCorporation

Recommended