There is a program that is to add and remove elements from the application collection, as follows:
<%@ Language=vbscript%>
<HTML>
<HEAD>
<title>the Application object</title>
<style type= "Text/css" >
body {font-family:tahoma,arial,sans-serif; font-size:10pt}
INPUT {font-family:tahoma,arial,sans-serif; font-size:9pt}
. heading {font-family:tahoma,arial,sans-serif; font-size:14pt; Font-weight:bold}
. subhead {font-family:tahoma,arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
. cite {font-family:tahoma,arial,sans-serif; font-size:8pt}
</STYLE>
</HEAD>
<body bgcolor= "#FFFFFF" >
<span class= "heading" >the ASP application
<!--------------------------------------------------------------------------->
<% ' Look for a command sent the FORM section buttons
If Len (Request.Form ("Cmdadd")) Then ' use whether length for 0来 judgment
Strvarname = Request.Form ("Txtvarname")
Strvarvalue = Request.Form ("Txtvarvalue")
Application.Lock
Application (strvarname) = Strvarvalue ' Here is an error
Application.UnLock
End If
If Len (Request.Form ("Cmdremovethis")) Then
Strtoremove = Request.Form ("Lstremove")
Application.Lock
Application.Contents.Remove (Strtoremove)
Application.UnLock
End If
If Len (Request.Form ("Cmdremoveall")) Then
Application.Lock
Application.Contents.RemoveAll
Application.UnLock
End If
%>
<p><div class= "subhead" >the application.contents collection</div>
<%
For each objitem in application.contents
If IsObject (application.contents (objitem)) Then
Response.Write "Object Reference: '" & objitem & "' <BR>"
ElseIf IsArray (application.contents (objitem)) Then
Response.Write "Array:" & objitem & "' Contents are:<br>"
Vararray = application.contents (objitem)
' note:the following with a one-dimensional array
For intloop = 0 to UBound (vararray)
Response.Write "Index (" & intloop & ") =" & Vararray (intloop) & "<BR>"
Next
Else
Response.Write "Variable:" "& objitem &" ' = "_
& Application.Contents (objitem) & "<BR>"
End If
Next
%>
<p><div class= "subhead" >the application.staticobjects collection</div>
<%
For each objitem in application.staticobjects
If IsObject (Application.staticobjects (objitem)) Then
Response.Write "<OBJECT> element:id= '" & Objitem & "<BR>"
End If
Next
%>
<!--collect values to execute application methods with-->
<form action= "<% = Request.ServerVariables (" Script_name ")%>" method= "POST" > "Using Request.ServerVariables ( "Script_name") submits the form to itself
<p><div class= "Subhead" >add a value to the application object</div>
<input type= "SUBMIT" name= "Cmdadd" "value=" ">
Application ("
<input type= "TEXT" name= "Txtvarname" size= "" value= "My_new_value" >
") = "
<input type= "TEXT" name= "Txtvarvalue" size= "value=" testing, testing ... ">
"<P>
<p><div class= "Subhead" >remove a value from application object</div>
<input type= "SUBMIT" name= "Cmdremovethis" "value=" ">
Application.Contents.Remove ("
<select name= "Lstremove" size= "1" >
<%
For each objitem in application.contents
Response.Write "<OPTION>" & Objitem & "</OPTION>"
Next
%>
</SELECT> ") <BR>
<input type= "SUBMIT" name= "Cmdremoveall" "value=" ">
Application.Contents.RemoveAll
</FORM>
<p><div class= "subhead" >other application methods</div>
Application.lock<br>
Application.unlock<p>
<!--------------------------------------------------------------------------->