Jump to content

Dictionaries


justsomeguy

Recommended Posts

I'm working with an ASP dictionary object, and I'm seeing some behavior that I can't explain. This is the code:

set dictObj = CreateObject("Scripting.Dictionary")response.write("<!-- created dictionary -->"&vbcrlf)while (not passing.eof)  if isnull(passing.fields.item("pass_score").value) or passing.fields.item("pass_score").value = "" then    passingscore = 0  else    passingscore = passing.fields.item("pass_score").value  end if  response.write("<!-- "&passingscore&" -->"&vbcrlf)  dictObj.Add passing.fields.item("cid").value, passingscore  response.write("<!-- "&passing.fields.item("cid").value&" -->"&vbcrlf)  response.write("<!-- "&dictObj.Item(passing.fields.item("cid").value)&" -->"&vbcrlf)  passing.movenext()wendpassing.close()dim cidscids = dictObj.Keys  ' all of the cids in the groupnumOf = UBound(cids) ' number of scores to checkresponse.write("<!-- there are "&numOf&" keys -->"&vbcrlf)

This is the output I'm getting:

<!-- created dictionary --><!-- 85 --><!-- url02 --><!-- 85 --><!-- there are 0 keys -->

The last line says that there are 0 keys in the dictionary, but I clearly add an item, with a key, and then immediately print it out again to verify that it is actually there (which it is). But then the Keys property is empty, or something else is going on.Can anyone see anything I'm missing?

Link to comment
Share on other sites

does declaring numOf make a difference? It doesn't appear to be declared.Or perhaps try this

UBound(dictObj.Keys)

I'm not too familiar witht he Dictionary object but I hope this helps a little.BTW, you don't get an errors do you?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...