Jump to content

ASP dictionary object question


tjodalv

Recommended Posts

Funny you should ask that, I did a lot of work last week with dictionaries and storing complex data structures under each key.I have no idea how, or if it is even possible, to do this with VBscript, if that is what you are using (and if you are, then you have my sympathy). But, if you are using Javascript, then it is both very easy and very powerful. You can use the generic object to store whatever you want:This is a simplified example from what I was working on:

var users = Server.CreateObject("Scripting.Dictionary");cur = new Object;cur.id = "your id";cur.fname = "your first name";cur.lname = "your last name";users.Add(cur.id, cur);...a_user = users.Item("your id");Response.write("The first name is " + a_user.fname + " and the last name is " + a_user.lname);

When you use the Javascript Object object, you can create whatever properties you want and assign values to them, and you can put the entire object in the dictionary. It worked great for me, I built a script to process 12,000 users from a CSV file, compare them against everyone in the database, and add or update whoever needs changes. It took a few minutes to run (dictionaries are fairly slow), but if you need a random-access data structure in ASP, dictionaries are about the only choice.

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...