travisbrown
Technical User
- Dec 31, 2001
- 1,016
So I can't figure this out. This should work, but it's allowing a duplicate key. I don't know how since it should throw an error, but the output is showing two of the same key.
I've got two arrays and trying to add them together in a dictionary, then into a MD array
I've got two arrays and trying to add them together in a dictionary, then into a MD array
Code:
Dim d
Set d=Server.CreateObject("Scripting.Dictionary")
IF isArray(existing_array) THEN
FOR i = 0 TO UBOUND(existing_array,2)
IF d.Exists(existing_array(0,i)) = TRUE THEN
d.Remove(existing_array(0,i))
END IF
d.Add existing_array(0,i),existing_array(1,i)
NEXT
END IF
'add new resources, check for duplicates
IF isArray(new_array) THEN
FOR i = 0 TO UBOUND(new_array,2)
IF d.Exists(new_array(0,i)) = TRUE THEN
d.Remove(new_array(0,i))
END IF
d.Add new_array(0,i),new_array(1,i)
NEXT
END IF
dictionary_size = d.count-1
DIM arrResourceArray()
REDIM arrResourceArray(2,dictionary_size)
a = d.keys
FOR i = 0 TO dictionary_size
arrResourceArray(0,i) = a(i)
arrResourceArray(1,i) = d.item(arrResourceArray(0,i))
response.write a(i) & "<br />"
NEXT
OUTPUT:
200
1007
1339
1534
1534