<!-- Declare instance of the ASPCounter component with application-level scope //--> <OBJECT ID=”ASPCounter” RUNAT=”Server” SCOPE=”Applicatoin” PROGID=”MSWC.Counters”> </OBJECT> <SCRIPT LANGUAGE=”VBScript” RUNAT=”Server”> Sub Application_onStart() ‘Create an instance of an ADO Connection with application-level scope Set Application(“ADOConnection”) = Server.CreateObject(“ADODB.Connection”) Dim varArray(3) ‘Create a Variant array and fill it varArray(0) = “This is a” varArray(1) = “Variant array” varArray(2) = “stored in the” varArray(3) = “Application object” Application(“Variant_Array”) = varArray ‘Store it in thd Application Application(“Start_Time”) = CStr(Now) ‘Store the date/time as a string Application(“Visit_Count”) = 0 ‘Set counter variable to zero End Sub </SCRIPT> |
For Each objItem in Application.Contents If IsObject(Application.Contents(objItem)) Then Response.Write “Object reference: ‘” & objItem & “’ ” ElseIf IsArray(Application.Contents(objItem)) Then Response.Write “Array: ‘” & objItem & “’ contents are: ” VarArray = Application.Contents(objItem) ‘Note: the following only works with a one-dimensional array For intLoop = 0 To UBound(varArray) Response.Write “ Index(“ & intLoop & “) = “ & _ VarArray(intLoop) & “ ” Next Else Response.Write “Variable: ‘” & objItem & “’ = “ _ & Application.Contents(objItem) & “ ” End If Next |
varArray = Application.Contents(objItem) |
For intLoop = 0 UBound(varArray) |
For intLoop = 0 To UBound(varArray) IntNumberOfDimensions = UBound(varArray, 1) For intDimension = 0 To intNumberOfDimensions Response.Write “ Index(“ & intLoop & “) = “ _ & varArray(intLoop, intDimension) Next Response.Write “” Next |
For Each objItem in Application.StaticObjects If IsObject(Application.StaticObjects(objItem)) Then Response.Write “<OBJECT> element: ID=’” & objItem & “’ ” End If Next |
<FORM ACTION=”<% = Request.ServerVariables(“SCRIPT_NAME”) %>” METHOD=”POST”> |
<INPUT TYPE=”SUBMIT” NAME=”cmdAdd” VALUE=” ”> |
If Len(Request.Form("cmdAdd")) Then strVarName = Request.Form("txtVarName") strVarValue = Request.Form("txtVarValue") Application.Lock Application("strVarName") = strVarValue Application.Unlock End If |
… <SELECT NAME=”lstRemove” SIZE=”1”> <% For Each objItem in Application.Contents Response.Write “<OPTION>” & objItem & “</OPTION>” Next &> </SELECT> … |
<SELECT NAME=”lstRemove” SIZE=”1”> <OPTION>ADOConnection</OPTION> <OPTION>Variant_Array</OPTION> <OPTION>Start_Time</OPTION> <OPTION>Visit_Count</OPTION> <OPTION>My_New_Value</OPTION> </SELECT> |
If Len(Request.Form("cmdRemoveThis")) Then strToRemove = Request.Form("lstRemove") Response.Write "strToRemove = " & strToRemove 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 |