The Dictionary class stores a collection of variables, with each variable indexed by a string key. The variables in the collection can be any valid VARIANT data subtype. This class is also not a COM class, and as such cannot be created stand-alone. It is an intrinsic class used by the other Active Channel Server classes. Collections that are marked as class Dictionary are essentially just properties that return the address of an IDispatch interface that exposes the methods and properties of this class. The methods and properties of this dispinterface are listed below.
The methods and properties of a Dictionary object are only accessible via a standard IDispatch COM interface. The members are listed below.
Name | Return Type | Parameters |
_NewEnum | IEnumVariant* (VT_DISPATCH) | (property) |
Count | Integer (VT_I4) | (property) |
Item | VT_XXXXX | String key (VT_BSTR) |
Synopsis
The Count property returns how many key/value pairs are in the dictionary.
The Item method returns the value for the key in the dictionary. Because this method is marked with id(DISPID_VALUE), it is the default method called when none is specified.
The _NewEnum property returns an IEnumVariant interface used to enumerate the collection. In most high level languages and scripting languages, this property is never requested directly. In Visual Basic, this property is used when the For Each Item In (Collection)
context is encountered.
Since the Item method is marked as [id(0)], it is the default method for the dispinterface. This allows for a nice short hand in languages that invoke methods through the dispinterface it that they need not specify the Item method by name.
Example
' assume we have a dictionary object called Dictionary
Dictionary.Item("favorite beethoven symphony") = "9th"
Dictionary("time") = "11/12/97"
Dictionary("level") = 42
Set Dictionary("logo") = CreateObject("Push.Logo")
Set Dictionary("channela") = CreateObject("Push.Channel")
' Note here that we can dispense with .Item since it is the
' default method for the object. See below
Note A key can be any string, number, or combination of both. However, case is ignored in the key:
Dictionary("This")
Dictionary("thIS")
Both of the above expressions refer to the same key, and thus the same associated value. If a key and value pair are added where the key passed has capital letters, these will be converted to the lower-case. Be careful with string comparisons that are case sensitive, such as against the strings stored in a LogoRefs collection.