An orderedDictionary allows a user to insert a key,value pair into a
specific location (index) of a dictionary.  It is also possible to
delete a key based upon its index.

Using an arrayList, it might be possible to create a sorted dictionary
and utilizing the insert method, to maintain the dictionary as
sorted.

It might make more sense to use the myEnumerator.movenext to create an
arrayList and use the sort method of the arrayList and then print out
the values.

hope this will be useful to some,

Parke

Set myDict =
DotnetFactory.CreateInstance("System.Collections.Specialized.OrderedDictionary")
Set myEnumerator =
DotnetFactory.CreateInstance("System.Collections.IDictionaryEnumerator")

myDict.add  "a", "apple"
myDict.add "o", "orange"
myDict.add  "r","red"
myDict.add "b", "blue"

Set myEnumerator = myDict.getEnumerator
print "Initial Dictionary"
While myEnumerator.movenext
        print "key " &myEnumerator.Key & ":: value " & myenumerator.value
Wend
print "myDict.count = " & myDict.count

' modify the dictionary
If Not myDict.isReadOnly Then
        ' insert at the beginning of the dictionary
        myDict.Insert 0, "m", "mango"
        ' insert inside the dictionary
        myDict.Insert 3, "y", "bannana"
End If

Set myEnumerator = myDict.getEnumerator
print vbcrlf
print "Dictionary after inserting two keys and values"
While myEnumerator.movenext
        print "key " &myEnumerator.Key & ":: value " & myenumerator.value
Wend
print "myDict.count = " & myDict.count

' and print a key, value pair as normal
print "key = r and value  = " & myDict("r")


-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to