ASP dictionary fun

ASP has a lot of “interesting” features shall we say. I’ve just been working with the dictionary object which is basically an array with named items, so everything has a key and value pair.

There is a method to add elements to it which accepts variables instead of literal text strings (as you would expect of course) but it doesn’t seem to accept variables in array.

For example, this will not work…

totals.Add RSTdata(“id”), 10
Response.Write(totals(RSTdata(“id”)))

However this will work just fine…

idNumber = RSTdata(“id”)
totals.Add idNumber, 10
Response.Write(totals(idNumber))

This isn’t quite as cool as the way ASP decides the forget about some variables but only after you’ve referenced them for the first time creating a rather nice heisenbug when you put in a few print lines but never the less interesting.

Timeline

Newsletter

Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.

Metadata

Tags: , , ,

This entry was posted on Thursday, May 7th, 2009 at 11:11 am and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.