PHP provides associative arrays but there is no such thing in classical asp. I am looking for a class or function that allows me to create and traverse a hierarchy similar to this:
United States
Washington
Electric City
Banks Lake
Lake Chelan
Wapato Point
Gig Harbour
Mexico
Nayarit
Aticama
Asia
India
Mumbai
Pakistan
Sindh
Karachi
As you can notice, the hierarchy has uneven depth — it could be 3, 4 or 5 levels deep. The database structure is even more complicated as for some records I have to start displaying data from region level while for others I should start from country. An array of arrays would really help but in ASP my hands are tied.
Its tempting to advise you to use JScript on the server side instead of VBScript. Not only does it do this sort of thing more naturally, you are likely to be familiar with the language. The downside is that the vast majority of “How-To” on the Web related to ASP is written in VBScript.
The associative array in VBScript is called the
Dictionaryis available from theScriptinglibrary. However to create a heirarchical structure you will probably need a little more help. I would create a class around theDictionaryso that I can hold more that just aNameproperty and to make heirarchical manipulation easier.Here is a sample class:-
Now you can create your tree:-
Now access this heirarchy as:-