Over the past few months, I've started seeing a less frequently used scripting object, Scripting::Dictionary, in scripts published in articles, books, and online. However, Windows Scripting Solutions readers who I've talked to say they rarely use the Scripting::Dictionary object in their scripts. Consequently, I thought I'd show you how the Dictionary object can make things a lot easier in certain types of scripts. "Understanding VBScript: The Dictionary ObjectAn Alternative to Arrays," June 2000, http://www.winscriptingsolutions.com, InstantDocID 8797, covers the basics, but I go into more depth.
Objects such as WScript, WshNetwork, and Scripting::Signer are Windows Script Host (WSH) objects; the Scripting::Dictionary object is one of two key objects that are part of the Microsoft Scripting Runtime Library (scrrun.dll). The other scrrun.dll object is the well-known Scripting::FileSystemObject. Given how frequently used this latter object is, it's strange that the former is so little known. Dictionary's obscurity is probably because of its name, which can be confusing to administrators without a development background. . . .


<BR>
25: While Not filInput1.AtEndOfStream <BR>
<DD>26: strLine = filInput1.ReadLine <BR>
<DD>27: dicData1.Add Split(strLine,",")(0), Split(strLine,",")(3) <BR>
28: Wend <BR>
<BR>
I get the error: <I>_05.vbs(27, 2) Microsoft VBScript runtime error: This key is already associated with an element of this collection.</I> Any ideas on why I get this error? The line numbers were added by me after running code. I used a comma deliminated file with a .txt ending not .csv. </P>
Jim Hunter July 16, 2003