Scripting Runtime Library(Dictionary)
Dictionary °³Ã¼ÀÇ Ç׸ñÀ» ¸ðµÎ Æ÷ÇÔÇÑ ¹è¿À» ¹ÝȯÇÑ´Ù.
object´Â Ç×»ó Dictionary °³Ã¼ÀÇ À̸§ÀÌ´Ù.
ÆĶó¸ÞÅÍ´Â ¾ø´Ù.
¹Ýȯ°ª oCollÀº Dictionary °³Ã¼ÀÇ Ç׸ñÀ» ¸ðµÎ Æ÷ÇÔÇÑ Ä÷º¼Ç ¹è¿À» ¹ÝȯÇÑ´Ù.
<SCRIPT language=JScript> function ItemsTest(){ var DicArr,dicObj,i,str=''; // º¯¼ö¸¦ ¸¸µç´Ù. dicObj=new ActiveXObject('Scripting.Dictionary'); dicObj.Add('a','»ç°ú'); // Å°¿Í Ç׸ñÀ» Ãß°¡ÇÑ´Ù. dicObj.Add('b','¹Ù³ª³ª'); dicObj.Add('c','ü¸®'); DicKeyArr=new VBArray(dicObj.Keys()).toArray(); // Å°¸¦ °¡Á®¿Â´Ù. DicArr=new VBArray(dicObj.Items()).toArray(); // Ç׸ñÀ» °¡Á®¿Â´Ù. for (i in DicArr){ // dictionary¸¦ ¹Ýº¹ÇÑ´Ù. str+=i+') '+DicKeyArr[i]+' : '+DicArr[i]+'<BR>'; } str+='<BR>dicObj.Count='+dicObj.Count; return(str); // °á°ú¸¦ ¹ÝȯÇÑ´Ù. } </SCRIPT> <DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="id=showjs.innerHTML=ItemsTest()"> <SPAN class=ie>JScript</SPAN> <SPAN class=method>Items</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>
<SCRIPT language=VBScript> Function ItemsTestvb Dim DicKeyArr,DicArr,dicObj,i ' º¯¼ö¸¦ ¸¸µç´Ù. str="" Set dicObj=CreateObject("Scripting.Dictionary") dicObj.Add "a","»ç°ú" ' Å°¿Í Ç׸ñÀ» Ãß°¡ÇÑ´Ù. dicObj.Add "b","¹Ù³ª³ª" dicObj.Add "c","ü¸®" DicKeyArr=dicObj.Keys ' Å°¸¦ °¡Á®¿Â´Ù. DicArr=dicObj.Items ' Ç׸ñÀ» °¡Á®¿Â´Ù. For i=0 To dicObj.Count-1 ' array¸¦ ¹Ýº¹ÇÑ´Ù. str=str&i&") "&DicKeyArr(i)&" : "&DicArr(i)&"<BR>" ' ¹Ýȯ ¹®ÀÚ¿À» ¸¸µç´Ù. Next str=str&"<BR>dicObj.Count="&dicObj.Count ItemsTestvb=str End Function </SCRIPT> <DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV> <DIV class=show onClick="showvb.innerHTML=ItemsTestvb()"> <SPAN class=ie>VBScript</SPAN> <SPAN class=method>Items</SPAN> ¸Þ¼µå ¿¹Á¦</DIV>