Regarding the dictionary object of script, I actually think that MS initially borrowed from dynamic scripting languages such as Python, and it was developed for clients. For this point, you can refer to page 137 of wrox's ASP Programmer's Reference Manual. Saving a dictionary object at the session level will reduce system performance, while saving a dictionary object at the application level will cause the web server to crash. I won’t say more about this.
Now we have to consider what design flaws there are when the dictionary object is on a single page:
You can try this
set rs=server.createobject(adodb.recordset)
sql=select * from table
rs.open sql,conn,1,3
set ttt=server.createobject(scripting.dictionary)
ttt.add xxx,rs(field)
set rs=nothing
liu=ttt(xxx) 'What will you find when you do this? The asp page will tell you that an accident occurred! ! ! This is very surprising. What is an accident? It's hard to say. Later, after repeated testing, I found out that it is because the value of rs(field) cannot be directly given to the dictionary object. After repeated research, I came to the following conclusion: dictionary stores the memory address of rs(field). In this case, what I just wrote is undoubtedly a disaster. The solution is to put this rs (field) into a variable. But can't the dictionary object save an object that has been changed by nothing? This is a big question, so I wrote this program again. You can save it as try.htm to see the effect.
<script language='vbscript'>
set ttt=createobject(scripting.dictionary)
ttt.add liu,uuu
set ddd=createobject(scripting.dictionary)
ddd.add ppp,ttt
setttt=nothing
bbb=ddd(ppp)(liu)
alert(bbb)
</script>
What's the result? You will find that there is no problem with the alert uuu description. This means that the dictionary object actually replaces another
The whole clone of the dictionary object comes in, which further verifies what is written in wrox's book that the dictionary object was used when ms was developed.
It's actually for the client, that's what I'm saying.
I can also show you the code for combining arrays and dictionaries.
<script language='vbscript'>
i=1
picname=(xxx)
str=set & pic_ & i & =createobject( & & scripting.dictionary & & )
execute(str)
str=pic_ & i & .add & & picname & & , & & picname &
execute(str)
dimttt()
redimttt(5)
ttt(0)=uuu
pic_1.add item,ttt
liu=pic_1(picname)
set pic_2=createobject(scripting.dictionary)
erasettt
redimttt(5)
ttt(0)=iii
nnn=pic_1(item)(0)
pic_2.add rrr,ttt
zzz=pic_2(rrr)(0)
alert(liu)
alert(nnn)
alert(zzz)
</script>