Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Scripts often retrieve information from an outside source, such as a text file or a database. After this information has been retrieved, it needs to be stored in memory so that the script can act upon it. Information such as this can be stored in individual variables (one variable for each bit of information) or in an array. Alternatively, information can also be stored in a Dictionary object.
The Dictionary object functions as an associative array; that is, it stores values in key-item pairs. This is different from an array, which uses a numeric index to store values. For example, a one-dimensional array consisting of state capitals might look like this:
By contrast, a Dictionary containing state capitals might look like this:
If your command-line arguments consist of single-item entries, such as computer names, you can use an array to hold the item names. However, the Dictionary object does offer several advantages over arrays. In particular, the Dictionary object does not require a script to:
This makes Dictionaries an ideal tool for system administration scripts that need to retrieve information such as server names from an outside source and then store that information in memory for later use.
Send us your feedback | « Previous | Next » |